5353 telemetry_client ,
5454 NoopTelemetryClient ,
5555)
56- from databricks .sql .telemetry .latency_logger import log_latency
57- from databricks .sql .telemetry .models .enums import DriverVolumeOperationType
56+
5857
5958logger = logging .getLogger (__name__ )
6059
@@ -457,9 +456,6 @@ def _close(self, close_cursors=True) -> None:
457456
458457 self .open = False
459458
460- if self .telemetry_enabled :
461- telemetry_client .close (self .get_session_id_hex ())
462-
463459 def commit (self ):
464460 """No-op because Databricks does not support transactions"""
465461 pass
@@ -517,10 +513,7 @@ def __iter__(self):
517513 for row in self .active_result_set :
518514 yield row
519515 else :
520- raise Error (
521- "There is no active result set" ,
522- connection_uuid = self .connection .get_session_id_hex (),
523- )
516+ raise Error ("There is no active result set" )
524517
525518 def _determine_parameter_approach (
526519 self , params : Optional [TParameterCollection ]
@@ -657,10 +650,7 @@ def _close_and_clear_active_result_set(self):
657650
658651 def _check_not_closed (self ):
659652 if not self .open :
660- raise Error (
661- "Attempting operation on closed cursor" ,
662- connection_uuid = self .connection .get_session_id_hex (),
663- )
653+ raise Error ("Attempting operation on closed cursor" )
664654
665655 def _handle_staging_operation (
666656 self , staging_allowed_local_path : Union [None , str , List [str ]]
@@ -678,8 +668,7 @@ def _handle_staging_operation(
678668 _staging_allowed_local_paths = staging_allowed_local_path
679669 else :
680670 raise Error (
681- "You must provide at least one staging_allowed_local_path when initialising a connection to perform ingestion commands" ,
682- connection_uuid = self .connection .get_session_id_hex (),
671+ "You must provide at least one staging_allowed_local_path when initialising a connection to perform ingestion commands"
683672 )
684673
685674 abs_staging_allowed_local_paths = [
@@ -708,8 +697,7 @@ def _handle_staging_operation(
708697 continue
709698 if not allow_operation :
710699 raise Error (
711- "Local file operations are restricted to paths within the configured staging_allowed_local_path" ,
712- connection_uuid = self .connection .get_session_id_hex (),
700+ "Local file operations are restricted to paths within the configured staging_allowed_local_path"
713701 )
714702
715703 # May be real headers, or could be json string
@@ -739,11 +727,9 @@ def _handle_staging_operation(
739727 else :
740728 raise Error (
741729 f"Operation { row .operation } is not supported. "
742- + "Supported operations are GET, PUT, and REMOVE" ,
743- connection_uuid = self .connection .get_session_id_hex (),
730+ + "Supported operations are GET, PUT, and REMOVE"
744731 )
745732
746- @log_latency ()
747733 def _handle_staging_put (
748734 self , presigned_url : str , local_file : str , headers : Optional [dict ] = None
749735 ):
@@ -753,13 +739,7 @@ def _handle_staging_put(
753739 """
754740
755741 if local_file is None :
756- raise Error (
757- "Cannot perform PUT without specifying a local_file" ,
758- connection_uuid = self .connection .get_session_id_hex (),
759- )
760-
761- self .volume_operation_type = DriverVolumeOperationType .PUT
762- self .volume_path = local_file
742+ raise Error ("Cannot perform PUT without specifying a local_file" )
763743
764744 with open (local_file , "rb" ) as fh :
765745 r = requests .put (url = presigned_url , data = fh , headers = headers )
@@ -776,8 +756,7 @@ def _handle_staging_put(
776756
777757 if r .status_code not in [OK , CREATED , NO_CONTENT , ACCEPTED ]:
778758 raise Error (
779- f"Staging operation over HTTP was unsuccessful: { r .status_code } -{ r .text } " ,
780- connection_uuid = self .connection .get_session_id_hex (),
759+ f"Staging operation over HTTP was unsuccessful: { r .status_code } -{ r .text } "
781760 )
782761
783762 if r .status_code == ACCEPTED :
@@ -786,7 +765,6 @@ def _handle_staging_put(
786765 + "but not yet applied on the server. It's possible this command may fail later."
787766 )
788767
789- @log_latency ()
790768 def _handle_staging_get (
791769 self , local_file : str , presigned_url : str , headers : Optional [dict ] = None
792770 ):
@@ -796,38 +774,25 @@ def _handle_staging_get(
796774 """
797775
798776 if local_file is None :
799- raise Error (
800- "Cannot perform GET without specifying a local_file" ,
801- connection_uuid = self .connection .get_session_id_hex (),
802- )
803-
804- self .volume_operation_type = DriverVolumeOperationType .GET
805- self .volume_path = local_file
777+ raise Error ("Cannot perform GET without specifying a local_file" )
806778
807779 r = requests .get (url = presigned_url , headers = headers )
808780
809781 # response.ok verifies the status code is not between 400-600.
810782 # Any 2xx or 3xx will evaluate r.ok == True
811783 if not r .ok :
812784 raise Error (
813- f"Staging operation over HTTP was unsuccessful: { r .status_code } -{ r .text } " ,
814- connection_uuid = self .connection .get_session_id_hex (),
785+ f"Staging operation over HTTP was unsuccessful: { r .status_code } -{ r .text } "
815786 )
816787
817788 with open (local_file , "wb" ) as fp :
818789 fp .write (r .content )
819790
820- @log_latency ()
821791 def _handle_staging_remove (
822792 self , presigned_url : str , headers : Optional [dict ] = None
823793 ):
824794 """Make an HTTP DELETE request to the presigned_url"""
825795
826- self .volume_operation_type = DriverVolumeOperationType .DELETE
827- self .volume_path = (
828- presigned_url # Using presigned URL as path since there's no local file
829- )
830-
831796 r = requests .delete (url = presigned_url , headers = headers )
832797
833798 if not r .ok :
@@ -1031,8 +996,7 @@ def get_async_execution_result(self):
1031996 return self
1032997 else :
1033998 raise Error (
1034- f"get_execution_result failed with Operation status { operation_state } " ,
1035- connection_uuid = self .connection .get_session_id_hex (),
999+ f"get_execution_result failed with Operation status { operation_state } "
10361000 )
10371001
10381002 def executemany (self , operation , seq_of_parameters ):
@@ -1182,10 +1146,7 @@ def fetchall(self) -> List[Row]:
11821146 if self .active_result_set :
11831147 return self .active_result_set .fetchall ()
11841148 else :
1185- raise Error (
1186- "There is no active result set" ,
1187- connection_uuid = self .connection .get_session_id_hex (),
1188- )
1149+ raise Error ("There is no active result set" )
11891150
11901151 def fetchone (self ) -> Optional [Row ]:
11911152 """
@@ -1199,10 +1160,7 @@ def fetchone(self) -> Optional[Row]:
11991160 if self .active_result_set :
12001161 return self .active_result_set .fetchone ()
12011162 else :
1202- raise Error (
1203- "There is no active result set" ,
1204- connection_uuid = self .connection .get_session_id_hex (),
1205- )
1163+ raise Error ("There is no active result set" )
12061164
12071165 def fetchmany (self , size : int ) -> List [Row ]:
12081166 """
@@ -1224,30 +1182,21 @@ def fetchmany(self, size: int) -> List[Row]:
12241182 if self .active_result_set :
12251183 return self .active_result_set .fetchmany (size )
12261184 else :
1227- raise Error (
1228- "There is no active result set" ,
1229- connection_uuid = self .connection .get_session_id_hex (),
1230- )
1185+ raise Error ("There is no active result set" )
12311186
12321187 def fetchall_arrow (self ) -> "pyarrow.Table" :
12331188 self ._check_not_closed ()
12341189 if self .active_result_set :
12351190 return self .active_result_set .fetchall_arrow ()
12361191 else :
1237- raise Error (
1238- "There is no active result set" ,
1239- connection_uuid = self .connection .get_session_id_hex (),
1240- )
1192+ raise Error ("There is no active result set" )
12411193
12421194 def fetchmany_arrow (self , size ) -> "pyarrow.Table" :
12431195 self ._check_not_closed ()
12441196 if self .active_result_set :
12451197 return self .active_result_set .fetchmany_arrow (size )
12461198 else :
1247- raise Error (
1248- "There is no active result set" ,
1249- connection_uuid = self .connection .get_session_id_hex (),
1250- )
1199+ raise Error ("There is no active result set" )
12511200
12521201 def cancel (self ) -> None :
12531202 """
0 commit comments