Skip to content

Commit 9092004

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 4148a2c commit 9092004

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
@@ -132,6 +132,13 @@ def __init__(
132132
# max_download_threads
133133
# Number of threads for handling cloud fetch downloads. Defaults to 10
134134

135+
logger.debug(
136+
"ThriftBackend.__init__(server_hostname=%s, port=%s, http_path=%s)",
137+
server_hostname,
138+
port,
139+
http_path,
140+
)
141+
135142
port = port or 443
136143
if kwargs.get("_connection_uri"):
137144
uri = kwargs.get("_connection_uri")
@@ -403,6 +410,8 @@ def attempt_request(attempt):
403410

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

413+
logger.error("ThriftBackend.attempt_request: HTTPError: %s", err)
414+
406415
gos_name = TCLIServiceClient.GetOperationStatus.__name__
407416
if method.__name__ == gos_name:
408417
delay_default = (
@@ -447,6 +456,7 @@ def attempt_request(attempt):
447456
else:
448457
logger.warning(log_string)
449458
except Exception as err:
459+
logger.error("ThriftBackend.attempt_request: Exception: %s", err)
450460
error = err
451461
retry_delay = extract_retry_delay(attempt)
452462
error_message = (
@@ -904,6 +914,12 @@ def execute_command(
904914
):
905915
assert session_handle is not None
906916

917+
logger.debug(
918+
"ThriftBackend.execute_command(operation=%s, session_handle=%s)",
919+
operation,
920+
session_handle,
921+
)
922+
907923
spark_arrow_types = ttypes.TSparkArrowTypes(
908924
timestampAsArrow=self._use_arrow_native_timestamps,
909925
decimalAsArrow=self._use_arrow_native_decimals,
@@ -1090,6 +1106,7 @@ def fetch_results(
10901106
return queue, resp.hasMoreRows
10911107

10921108
def close_command(self, op_handle):
1109+
logger.debug("ThriftBackend.close_command(op_handle=%s)", op_handle)
10931110
req = ttypes.TCloseOperationReq(operationHandle=op_handle)
10941111
resp = self.make_request(self._client.CloseOperation, req)
10951112
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)