Skip to content

Commit 8759bcd

Browse files
saishreeeeevarun-edachali-dbx
authored andcommitted
PECOBLR-86 improve logging on python driver (#556)
* PECOBLR-86 Improve logging for debug level Signed-off-by: Sai Shree Pradhan <[email protected]> * PECOBLR-86 Improve logging for debug level Signed-off-by: Sai Shree Pradhan <[email protected]> * fixed format Signed-off-by: Sai Shree Pradhan <[email protected]> * used lazy logging Signed-off-by: Sai Shree Pradhan <[email protected]> * changed debug to error logs Signed-off-by: Sai Shree Pradhan <[email protected]> * used lazy logging Signed-off-by: Sai Shree Pradhan <[email protected]> --------- Signed-off-by: Sai Shree Pradhan <[email protected]> Signed-off-by: varun-edachali-dbx <[email protected]>
1 parent 8c9f0c9 commit 8759bcd

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/databricks/sql/backend/thrift_backend.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ def __init__(
133133
# max_download_threads
134134
# Number of threads for handling cloud fetch downloads. Defaults to 10
135135

136+
logger.debug(
137+
"ThriftBackend.__init__(server_hostname=%s, port=%s, http_path=%s)",
138+
server_hostname,
139+
port,
140+
http_path,
141+
)
142+
136143
port = port or 443
137144
if kwargs.get("_connection_uri"):
138145
uri = kwargs.get("_connection_uri")
@@ -404,6 +411,8 @@ def attempt_request(attempt):
404411

405412
# TODO: don't use exception handling for GOS polling...
406413

414+
logger.error("ThriftBackend.attempt_request: HTTPError: %s", err)
415+
407416
gos_name = TCLIServiceClient.GetOperationStatus.__name__
408417
if method.__name__ == gos_name:
409418
delay_default = (
@@ -448,6 +457,7 @@ def attempt_request(attempt):
448457
else:
449458
logger.warning(log_string)
450459
except Exception as err:
460+
logger.error("ThriftBackend.attempt_request: Exception: %s", err)
451461
error = err
452462
retry_delay = extract_retry_delay(attempt)
453463
error_message = (
@@ -914,6 +924,12 @@ def execute_command(
914924
):
915925
assert session_handle is not None
916926

927+
logger.debug(
928+
"ThriftBackend.execute_command(operation=%s, session_handle=%s)",
929+
operation,
930+
session_handle,
931+
)
932+
917933
spark_arrow_types = ttypes.TSparkArrowTypes(
918934
timestampAsArrow=self._use_arrow_native_timestamps,
919935
decimalAsArrow=self._use_arrow_native_decimals,
@@ -1150,6 +1166,7 @@ def fetch_results(
11501166
return queue, resp.hasMoreRows
11511167

11521168
def close_command(self, op_handle):
1169+
logger.debug("ThriftBackend.close_command(op_handle=%s)", op_handle)
11531170
req = ttypes.TCloseOperationReq(operationHandle=op_handle)
11541171
resp = self.make_request(self._client.CloseOperation, req)
11551172
return resp.status

src/databricks/sql/client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ def read(self) -> Optional[OAuthToken]:
216216
# use_cloud_fetch
217217
# Enable use of cloud fetch to extract large query results in parallel via cloud storage
218218

219+
logger.debug(
220+
"Connection.__init__(server_hostname=%s, http_path=%s)",
221+
server_hostname,
222+
http_path,
223+
)
224+
219225
if access_token:
220226
access_token_kv = {"access_token": access_token}
221227
kwargs = {**kwargs, **access_token_kv}
@@ -745,6 +751,9 @@ def execute(
745751
746752
:returns self
747753
"""
754+
logger.debug(
755+
"Cursor.execute(operation=%s, parameters=%s)", operation, parameters
756+
)
748757

749758
param_approach = self._determine_parameter_approach(parameters)
750759
if param_approach == ParameterApproach.NONE:

0 commit comments

Comments
 (0)