@@ -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
155155def 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 )
0 commit comments