Skip to content

Commit 804f9e0

Browse files
committed
formatting
Signed-off-by: Sai Shree Pradhan <saishree.pradhan@databricks.com>
1 parent 928e128 commit 804f9e0

File tree

5 files changed

+37
-18
lines changed

5 files changed

+37
-18
lines changed

src/databricks/sql/backend/thrift_backend.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,9 +1022,11 @@ def execute_command(
10221022
self._handle_execute_response_async(resp, cursor)
10231023
return None
10241024
else:
1025-
execute_response, is_direct_results, statement_id = self._handle_execute_response(
1026-
resp, cursor
1027-
)
1025+
(
1026+
execute_response,
1027+
is_direct_results,
1028+
statement_id,
1029+
) = self._handle_execute_response(resp, cursor)
10281030

10291031
t_row_set = None
10301032
if resp.directResults and resp.directResults.resultSet:
@@ -1248,7 +1250,11 @@ def _handle_execute_response(self, resp, cursor):
12481250
resp, final_operation_state
12491251
)
12501252

1251-
return execute_response, is_direct_results, cursor.active_command_id.to_hex_guid()
1253+
return (
1254+
execute_response,
1255+
is_direct_results,
1256+
cursor.active_command_id.to_hex_guid(),
1257+
)
12521258

12531259
def _handle_execute_response_async(self, resp, cursor):
12541260
command_id = CommandId.from_thrift_handle(resp.operationHandle)
@@ -1306,7 +1312,7 @@ def fetch_results(
13061312
description=description,
13071313
ssl_options=self._ssl_options,
13081314
session_id_hex=self._session_id_hex,
1309-
statement_id=statement_id
1315+
statement_id=statement_id,
13101316
)
13111317

13121318
return queue, resp.hasMoreRows

src/databricks/sql/cloudfetch/download_manager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,17 @@ def _schedule_downloads(self):
9595
):
9696
chunk_id, link = self._pending_links.pop(0)
9797
logger.debug(
98-
"- chunk: {}, start: {}, row count: {}".format(chunk_id, link.startRowOffset, link.rowCount)
98+
"- chunk: {}, start: {}, row count: {}".format(
99+
chunk_id, link.startRowOffset, link.rowCount
100+
)
99101
)
100102
handler = ResultSetDownloadHandler(
101103
settings=self._downloadable_result_settings,
102104
link=link,
103105
ssl_options=self._ssl_options,
104106
chunk_id=chunk_id,
105107
session_id_hex=self.session_id_hex,
106-
statement_id=self.statement_id
108+
statement_id=self.statement_id,
107109
)
108110
task = self._thread_pool.submit(handler.run)
109111
self._download_tasks.append(task)

src/databricks/sql/telemetry/latency_logger.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ def get_is_compressed(self) -> bool:
6565
def get_execution_result(self) -> ExecutionResultFormat:
6666
if self.active_result_set is None:
6767
return ExecutionResultFormat.FORMAT_UNSPECIFIED
68-
68+
6969
from databricks.sql.utils import ColumnQueue, CloudFetchQueue, ArrowQueue
70+
7071
if isinstance(self.active_result_set.results, ColumnQueue):
7172
return ExecutionResultFormat.COLUMNAR_INLINE
7273
elif isinstance(self.active_result_set.results, CloudFetchQueue):
@@ -76,13 +77,10 @@ def get_execution_result(self) -> ExecutionResultFormat:
7677
return ExecutionResultFormat.FORMAT_UNSPECIFIED
7778

7879
def get_retry_count(self) -> int:
79-
if (
80-
hasattr(self.backend, "retry_policy")
81-
and self.backend.retry_policy
82-
):
80+
if hasattr(self.backend, "retry_policy") and self.backend.retry_policy:
8381
return len(self.backend.retry_policy.history)
8482
return 0
85-
83+
8684
def get_chunk_id(self):
8785
return None
8886

@@ -108,6 +106,7 @@ def get_is_compressed(self) -> bool:
108106

109107
def get_execution_result(self) -> ExecutionResultFormat:
110108
from databricks.sql.utils import ColumnQueue, CloudFetchQueue, ArrowQueue
109+
111110
if isinstance(self.results, ColumnQueue):
112111
return ExecutionResultFormat.COLUMNAR_INLINE
113112
elif isinstance(self.results, CloudFetchQueue):
@@ -123,7 +122,7 @@ def get_retry_count(self) -> int:
123122
):
124123
return len(self.thrift_backend.retry_policy.history)
125124
return 0
126-
125+
127126
def get_chunk_id(self):
128127
return None
129128

@@ -132,6 +131,7 @@ class ResultSetDownloadHandlerExtractor(TelemetryExtractor):
132131
"""
133132
Telemetry extractor specialized for ResultSetDownloadHandler objects.
134133
"""
134+
135135
def get_session_id_hex(self) -> Optional[str]:
136136
return self._obj.session_id_hex
137137

@@ -150,7 +150,7 @@ def get_retry_count(self) -> Optional[int]:
150150

151151
def get_chunk_id(self) -> Optional[int]:
152152
return self._obj.chunk_id
153-
153+
154154

155155
def get_extractor(obj):
156156
"""
@@ -174,7 +174,7 @@ def get_extractor(obj):
174174
return CursorExtractor(obj)
175175
elif obj.__class__.__name__ == "ResultSet":
176176
return ResultSetExtractor(obj)
177-
elif obj.__class__.__name__=="ResultSetDownloadHandler":
177+
elif obj.__class__.__name__ == "ResultSetDownloadHandler":
178178
return ResultSetDownloadHandlerExtractor(obj)
179179
else:
180180
logger.debug("No extractor found for %s", obj.__class__.__name__)
@@ -233,7 +233,17 @@ def _safe_call(func_to_call):
233233
duration_ms = int((end_time - start_time) * 1000)
234234

235235
extractor = get_extractor(self)
236-
print("function name", func.__name__, "latency", duration_ms, "session_id_hex", extractor.get_session_id_hex(), "statement_id", extractor.get_statement_id(), flush=True)
236+
print(
237+
"function name",
238+
func.__name__,
239+
"latency",
240+
duration_ms,
241+
"session_id_hex",
242+
extractor.get_session_id_hex(),
243+
"statement_id",
244+
extractor.get_statement_id(),
245+
flush=True,
246+
)
237247

238248
if extractor is not None:
239249
session_id_hex = _safe_call(extractor.get_session_id_hex)

src/databricks/sql/telemetry/models/event.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class SqlExecutionEvent(JsonSerializableMixin):
131131
retry_count: Optional[int]
132132
chunk_id: Optional[int]
133133

134+
134135
@dataclass
135136
class TelemetryEvent(JsonSerializableMixin):
136137
"""

src/databricks/sql/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def __init__(
239239
self._ssl_options = ssl_options
240240
self.session_id_hex = session_id_hex
241241
self.statement_id = statement_id
242-
242+
243243
logger.debug(
244244
"Initialize CloudFetch loader, row set start offset: {}, file list:".format(
245245
start_row_offset

0 commit comments

Comments
 (0)