@@ -735,7 +735,7 @@ def convert_col(t_column_desc):
735735 return pyarrow .schema ([convert_col (col ) for col in t_table_schema .columns ])
736736
737737 @staticmethod
738- def _col_to_description (col , field , session_id_hex = None ):
738+ def _col_to_description (col , field = None , session_id_hex = None ):
739739 type_entry = col .typeDesc .types [0 ]
740740
741741 if type_entry .primitiveEntry :
@@ -778,7 +778,9 @@ def _col_to_description(col, field, session_id_hex=None):
778778 return col .columnName , cleaned_type , None , None , precision , scale , None
779779
780780 @staticmethod
781- def _hive_schema_to_description (t_table_schema , schema_bytes = None , session_id_hex = None ):
781+ def _hive_schema_to_description (
782+ t_table_schema , schema_bytes = None , session_id_hex = None
783+ ):
782784 field_dict = {}
783785 if pyarrow and schema_bytes :
784786 try :
@@ -788,8 +790,13 @@ def _hive_schema_to_description(t_table_schema, schema_bytes=None, session_id_he
788790 field_dict [field .name ] = field
789791 except Exception as e :
790792 logger .debug (f"Could not parse arrow schema: { e } " )
793+
791794 return [
792- ThriftDatabricksClient ._col_to_description (col , field_dict .get (col .columnName ), session_id_hex )
795+ ThriftDatabricksClient ._col_to_description (
796+ col ,
797+ field_dict .get (col .columnName ) if field_dict else None ,
798+ session_id_hex ,
799+ )
793800 for col in t_table_schema .columns
794801 ]
795802
@@ -822,11 +829,6 @@ def _results_message_to_execute_response(self, resp, operation_state):
822829 or direct_results .resultSet .hasMoreRows
823830 )
824831
825- description = self ._hive_schema_to_description (
826- t_result_set_metadata_resp .schema ,
827- self ._session_id_hex ,
828- )
829-
830832 if pyarrow :
831833 schema_bytes = (
832834 t_result_set_metadata_resp .arrowSchema
@@ -840,7 +842,9 @@ def _results_message_to_execute_response(self, resp, operation_state):
840842 schema_bytes = None
841843
842844 description = self ._hive_schema_to_description (
843- t_result_set_metadata_resp .schema , schema_bytes
845+ t_result_set_metadata_resp .schema ,
846+ schema_bytes ,
847+ self ._session_id_hex ,
844848 )
845849
846850 lz4_compressed = t_result_set_metadata_resp .lz4Compressed
@@ -887,11 +891,6 @@ def get_execution_result(
887891
888892 t_result_set_metadata_resp = resp .resultSetMetadata
889893
890- description = self ._hive_schema_to_description (
891- t_result_set_metadata_resp .schema ,
892- self ._session_id_hex ,
893- )
894-
895894 if pyarrow :
896895 schema_bytes = (
897896 t_result_set_metadata_resp .arrowSchema
@@ -904,6 +903,12 @@ def get_execution_result(
904903 else :
905904 schema_bytes = None
906905
906+ description = self ._hive_schema_to_description (
907+ t_result_set_metadata_resp .schema ,
908+ schema_bytes ,
909+ self ._session_id_hex ,
910+ )
911+
907912 lz4_compressed = t_result_set_metadata_resp .lz4Compressed
908913 is_staging_operation = t_result_set_metadata_resp .isStagingOperation
909914 has_more_rows = resp .hasMoreRows
0 commit comments