@@ -28,52 +28,52 @@ def _extract_cursor_data(cursor) -> Dict[str, Any]:
2828
2929 # Extract statement_id (query_id) - direct attribute access
3030 try :
31- data [' statement_id' ] = cursor .query_id
31+ data [" statement_id" ] = cursor .query_id
3232 except (AttributeError , Exception ):
33- data [' statement_id' ] = None
33+ data [" statement_id" ] = None
3434
3535 # Extract session_id_hex - direct method call
3636 try :
37- data [' session_id_hex' ] = cursor .connection .get_session_id_hex ()
37+ data [" session_id_hex" ] = cursor .connection .get_session_id_hex ()
3838 except (AttributeError , Exception ):
39- data [' session_id_hex' ] = None
39+ data [" session_id_hex" ] = None
4040
4141 # Extract is_compressed - direct attribute access
4242 try :
43- data [' is_compressed' ] = cursor .connection .lz4_compression
43+ data [" is_compressed" ] = cursor .connection .lz4_compression
4444 except (AttributeError , Exception ):
45- data [' is_compressed' ] = False
45+ data [" is_compressed" ] = False
4646
4747 # Extract execution_result_format - inline logic
4848 try :
4949 if cursor .active_result_set is None :
50- data [' execution_result' ] = ExecutionResultFormat .FORMAT_UNSPECIFIED
50+ data [" execution_result" ] = ExecutionResultFormat .FORMAT_UNSPECIFIED
5151 else :
5252 from databricks .sql .utils import ColumnQueue , CloudFetchQueue , ArrowQueue
5353
5454 results = cursor .active_result_set .results
5555 if isinstance (results , ColumnQueue ):
56- data [' execution_result' ] = ExecutionResultFormat .COLUMNAR_INLINE
56+ data [" execution_result" ] = ExecutionResultFormat .COLUMNAR_INLINE
5757 elif isinstance (results , CloudFetchQueue ):
58- data [' execution_result' ] = ExecutionResultFormat .EXTERNAL_LINKS
58+ data [" execution_result" ] = ExecutionResultFormat .EXTERNAL_LINKS
5959 elif isinstance (results , ArrowQueue ):
60- data [' execution_result' ] = ExecutionResultFormat .INLINE_ARROW
60+ data [" execution_result" ] = ExecutionResultFormat .INLINE_ARROW
6161 else :
62- data [' execution_result' ] = ExecutionResultFormat .FORMAT_UNSPECIFIED
62+ data [" execution_result" ] = ExecutionResultFormat .FORMAT_UNSPECIFIED
6363 except (AttributeError , Exception ):
64- data [' execution_result' ] = ExecutionResultFormat .FORMAT_UNSPECIFIED
64+ data [" execution_result" ] = ExecutionResultFormat .FORMAT_UNSPECIFIED
6565
6666 # Extract retry_count - direct attribute access
6767 try :
6868 if hasattr (cursor .backend , "retry_policy" ) and cursor .backend .retry_policy :
69- data [' retry_count' ] = len (cursor .backend .retry_policy .history )
69+ data [" retry_count" ] = len (cursor .backend .retry_policy .history )
7070 else :
71- data [' retry_count' ] = 0
71+ data [" retry_count" ] = 0
7272 except (AttributeError , Exception ):
73- data [' retry_count' ] = 0
73+ data [" retry_count" ] = 0
7474
7575 # chunk_id is always None for Cursor
76- data [' chunk_id' ] = None
76+ data [" chunk_id" ] = None
7777
7878 return data
7979
@@ -94,33 +94,33 @@ def _extract_result_set_handler_data(handler) -> Dict[str, Any]:
9494
9595 # Extract session_id_hex - direct attribute access
9696 try :
97- data [' session_id_hex' ] = handler .session_id_hex
97+ data [" session_id_hex" ] = handler .session_id_hex
9898 except (AttributeError , Exception ):
99- data [' session_id_hex' ] = None
99+ data [" session_id_hex" ] = None
100100
101101 # Extract statement_id - direct attribute access
102102 try :
103- data [' statement_id' ] = handler .statement_id
103+ data [" statement_id" ] = handler .statement_id
104104 except (AttributeError , Exception ):
105- data [' statement_id' ] = None
105+ data [" statement_id" ] = None
106106
107107 # Extract is_compressed - direct attribute access
108108 try :
109- data [' is_compressed' ] = handler .settings .is_lz4_compressed
109+ data [" is_compressed" ] = handler .settings .is_lz4_compressed
110110 except (AttributeError , Exception ):
111- data [' is_compressed' ] = False
111+ data [" is_compressed" ] = False
112112
113113 # execution_result is always EXTERNAL_LINKS for result set handlers
114- data [' execution_result' ] = ExecutionResultFormat .EXTERNAL_LINKS
114+ data [" execution_result" ] = ExecutionResultFormat .EXTERNAL_LINKS
115115
116116 # retry_count is not available for result set handlers
117- data [' retry_count' ] = None
117+ data [" retry_count" ] = None
118118
119119 # Extract chunk_id - direct attribute access
120120 try :
121- data [' chunk_id' ] = handler .chunk_id
121+ data [" chunk_id" ] = handler .chunk_id
122122 except (AttributeError , Exception ):
123- data [' chunk_id' ] = None
123+ data [" chunk_id" ] = None
124124
125125 return data
126126
@@ -193,9 +193,9 @@ def wrapper(self, *args, **kwargs):
193193
194194 # Fast check: use cached telemetry_enabled flag from connection
195195 # Avoids dictionary lookup + instance check on every operation
196- connection = getattr (self , ' connection' , None )
196+ connection = getattr (self , " connection" , None )
197197 if not connection or not getattr (
198- connection , ' telemetry_enabled' , False
198+ connection , " telemetry_enabled" , False
199199 ):
200200 return
201201
@@ -210,10 +210,10 @@ def wrapper(self, *args, **kwargs):
210210
211211 sql_exec_event = SqlExecutionEvent (
212212 statement_type = statement_type ,
213- is_compressed = telemetry_data .get (' is_compressed' ),
214- execution_result = telemetry_data .get (' execution_result' ),
215- retry_count = telemetry_data .get (' retry_count' ),
216- chunk_id = telemetry_data .get (' chunk_id' ),
213+ is_compressed = telemetry_data .get (" is_compressed" ),
214+ execution_result = telemetry_data .get (" execution_result" ),
215+ retry_count = telemetry_data .get (" retry_count" ),
216+ chunk_id = telemetry_data .get (" chunk_id" ),
217217 )
218218
219219 telemetry_client = TelemetryClientFactory .get_telemetry_client (
@@ -222,7 +222,7 @@ def wrapper(self, *args, **kwargs):
222222 telemetry_client .export_latency_log (
223223 latency_ms = duration_ms ,
224224 sql_execution_event = sql_exec_event ,
225- sql_statement_id = telemetry_data .get (' statement_id' ),
225+ sql_statement_id = telemetry_data .get (" statement_id" ),
226226 )
227227
228228 return wrapper
0 commit comments