Skip to content

Commit b0f5ca6

Browse files
Niall Egansusodapop
authored andcommitted
API tweaks for Redash use
Add arg to disable username / password check and add direct fetcharrow methods to make things easier to use. Author: Niall Egan <niall.egan@databricks.com>
1 parent 689db6b commit b0f5ca6

File tree

1 file changed

+18
-2
lines changed
  • cmdexec/clients/python/src/databricks/sql

1 file changed

+18
-2
lines changed

cmdexec/clients/python/src/databricks/sql/client.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ def __init__(self,
7474
# Tag to add to User-Agent header. For use by partners.
7575
# _username, _password
7676
# Username and password Basic authentication (no official support)
77+
# _use_cert_as_auth
78+
# Use a TLS cert instead of a token or username / password (internal use only)
7779
# _enable_ssl
7880
# Connect over HTTP instead of HTTPS
7981
# _port
@@ -100,8 +102,8 @@ def __init__(self,
100102
authorization_header = "Basic {}".format(auth_credentials_base64)
101103
elif access_token:
102104
authorization_header = "Bearer {}".format(access_token)
103-
else:
104-
raise ValueError("No valid authentication settings.")
105+
elif not (kwargs.get("_use_cert_as_auth") and kwargs.get("_tls_client_cert_file")):
106+
raise ValueError("No valid authentication settings. Please provide an access token.")
105107

106108
if not kwargs.get("_user_agent_entry"):
107109
useragent_header = "{}/{}".format(USER_AGENT_NAME, __version__)
@@ -423,6 +425,20 @@ def fetchmany(self, n_rows: int) -> List[Tuple]:
423425
else:
424426
raise Error("There is no active result set")
425427

428+
def fetchall_arrow(self):
429+
self._check_not_closed()
430+
if self.active_result_set:
431+
return self.active_result_set.fetchall_arrow()
432+
else:
433+
raise Error("There is no active result set")
434+
435+
def fetchmany_arrow(self, n_rows):
436+
self._check_not_closed()
437+
if self.active_result_set:
438+
return self.active_result_set.fetchmany_arrow(n_rows)
439+
else:
440+
raise Error("There is no active result set")
441+
426442
def cancel(self) -> None:
427443
"""
428444
Cancel a running command.

0 commit comments

Comments
 (0)