Skip to content

Commit d527a9d

Browse files
committed
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]>
1 parent 6354c97 commit d527a9d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/databricks/sql/client.py

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

217+
logger.debug(
218+
"Connection.__init__(server_hostname=%s, http_path=%s)",
219+
server_hostname,
220+
http_path,
221+
)
222+
217223
if access_token:
218224
access_token_kv = {"access_token": access_token}
219225
kwargs = {**kwargs, **access_token_kv}
@@ -800,6 +806,9 @@ def execute(
800806
801807
:returns self
802808
"""
809+
logger.debug(
810+
"Cursor.execute(operation=%s, parameters=%s)", operation, parameters
811+
)
803812

804813
param_approach = self._determine_parameter_approach(parameters)
805814
if param_approach == ParameterApproach.NONE:

src/databricks/sql/thrift_backend.py

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

134+
logger.debug(
135+
"ThriftBackend.__init__(server_hostname=%s, port=%s, http_path=%s)",
136+
server_hostname,
137+
port,
138+
http_path,
139+
)
140+
134141
port = port or 443
135142
if kwargs.get("_connection_uri"):
136143
uri = kwargs.get("_connection_uri")
@@ -390,6 +397,8 @@ def attempt_request(attempt):
390397

391398
# TODO: don't use exception handling for GOS polling...
392399

400+
logger.error("ThriftBackend.attempt_request: HTTPError: %s", err)
401+
393402
gos_name = TCLIServiceClient.GetOperationStatus.__name__
394403
if method.__name__ == gos_name:
395404
delay_default = (
@@ -434,6 +443,7 @@ def attempt_request(attempt):
434443
else:
435444
logger.warning(log_string)
436445
except Exception as err:
446+
logger.error("ThriftBackend.attempt_request: Exception: %s", err)
437447
error = err
438448
retry_delay = extract_retry_delay(attempt)
439449
error_message = ThriftBackend._extract_error_message_from_headers(
@@ -888,6 +898,12 @@ def execute_command(
888898
):
889899
assert session_handle is not None
890900

901+
logger.debug(
902+
"ThriftBackend.execute_command(operation=%s, session_handle=%s)",
903+
operation,
904+
session_handle,
905+
)
906+
891907
spark_arrow_types = ttypes.TSparkArrowTypes(
892908
timestampAsArrow=self._use_arrow_native_timestamps,
893909
decimalAsArrow=self._use_arrow_native_decimals,
@@ -1074,6 +1090,7 @@ def fetch_results(
10741090
return queue, resp.hasMoreRows
10751091

10761092
def close_command(self, op_handle):
1093+
logger.debug("ThriftBackend.close_command(op_handle=%s)", op_handle)
10771094
req = ttypes.TCloseOperationReq(operationHandle=op_handle)
10781095
resp = self.make_request(self._client.CloseOperation, req)
10791096
return resp.status

0 commit comments

Comments
 (0)