Skip to content

Commit 5117787

Browse files
committed
used lazy logging
Signed-off-by: Sai Shree Pradhan <saishree.pradhan@databricks.com>
1 parent 0adfedd commit 5117787

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/databricks/sql/client.py

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

217217
logger.debug(
218-
f"Connection.__init__(server_hostname={server_hostname}, http_path={http_path})"
218+
"Connection.__init__(server_hostname=%s, http_path=%s)",
219+
server_hostname,
220+
http_path,
219221
)
220222

221223
if access_token:
@@ -791,7 +793,9 @@ def execute(
791793
792794
:returns self
793795
"""
794-
logger.debug(f"Cursor.execute(operation={operation}, parameters={parameters})")
796+
logger.debug(
797+
"Cursor.execute(operation=%s, parameters=%s)", operation, parameters
798+
)
795799

796800
param_approach = self._determine_parameter_approach(parameters)
797801
if param_approach == ParameterApproach.NONE:

src/databricks/sql/thrift_backend.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ def __init__(
132132
# Number of threads for handling cloud fetch downloads. Defaults to 10
133133

134134
logger.debug(
135-
f"ThriftBackend.__init__(server_hostname={server_hostname}, port={port}, http_path={http_path})"
135+
"ThriftBackend.__init__(server_hostname=%s, port=%s, http_path=%s)",
136+
server_hostname,
137+
port,
138+
http_path,
136139
)
137140

138141
port = port or 443
@@ -394,7 +397,7 @@ def attempt_request(attempt):
394397

395398
# TODO: don't use exception handling for GOS polling...
396399

397-
logger.error(f"ThriftBackend.attempt_request: HTTPError: {err}")
400+
logger.error("ThriftBackend.attempt_request: HTTPError: %s", err)
398401

399402
gos_name = TCLIServiceClient.GetOperationStatus.__name__
400403
if method.__name__ == gos_name:
@@ -410,7 +413,7 @@ def attempt_request(attempt):
410413
else:
411414
raise err
412415
except OSError as err:
413-
logger.error(f"ThriftBackend.attempt_request: OSError: {err}")
416+
logger.error("ThriftBackend.attempt_request: OSError: %s", err)
414417
error = err
415418
error_message = str(err)
416419
# fmt: off
@@ -441,7 +444,7 @@ def attempt_request(attempt):
441444
else:
442445
logger.warning(log_string)
443446
except Exception as err:
444-
logger.error(f"ThriftBackend.attempt_request: Exception: {err}")
447+
logger.error("ThriftBackend.attempt_request: Exception: %s", err)
445448
error = err
446449
retry_delay = extract_retry_delay(attempt)
447450
error_message = ThriftBackend._extract_error_message_from_headers(
@@ -897,7 +900,9 @@ def execute_command(
897900
assert session_handle is not None
898901

899902
logger.debug(
900-
f"ThriftBackend.execute_command(operation={operation}, session_handle={session_handle})"
903+
"ThriftBackend.execute_command(operation=%s, session_handle=%s)",
904+
operation,
905+
session_handle,
901906
)
902907

903908
spark_arrow_types = ttypes.TSparkArrowTypes(

0 commit comments

Comments
 (0)