@@ -133,7 +133,7 @@ def test_hive_schema_to_arrow_schema_preserves_column_names(self):
133
133
self .assertEqual (arrow_schema .field (2 ).name , "column 2" )
134
134
self .assertEqual (arrow_schema .field (3 ).name , "" )
135
135
136
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
136
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
137
137
def test_bad_protocol_versions_are_rejected (self , tcli_service_client_cass ):
138
138
t_http_client_instance = tcli_service_client_cass .return_value
139
139
bad_protocol_versions = [
@@ -163,7 +163,7 @@ def test_bad_protocol_versions_are_rejected(self, tcli_service_client_cass):
163
163
"expected server to use a protocol version" , str (cm .exception )
164
164
)
165
165
166
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
166
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
167
167
def test_okay_protocol_versions_succeed (self , tcli_service_client_cass ):
168
168
t_http_client_instance = tcli_service_client_cass .return_value
169
169
good_protocol_versions = [
@@ -642,7 +642,7 @@ def test_handle_execute_response_sets_compression_in_direct_results(
642
642
)
643
643
self .assertEqual (execute_response .lz4_compressed , lz4Compressed )
644
644
645
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
645
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
646
646
def test_handle_execute_response_checks_operation_state_in_polls (
647
647
self , tcli_service_class
648
648
):
@@ -686,7 +686,7 @@ def test_handle_execute_response_checks_operation_state_in_polls(
686
686
if op_state_resp .errorMessage :
687
687
self .assertIn (op_state_resp .errorMessage , str (cm .exception ))
688
688
689
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
689
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
690
690
def test_get_status_uses_display_message_if_available (self , tcli_service_class ):
691
691
tcli_service_instance = tcli_service_class .return_value
692
692
@@ -724,7 +724,7 @@ def test_get_status_uses_display_message_if_available(self, tcli_service_class):
724
724
self .assertEqual (display_message , str (cm .exception ))
725
725
self .assertIn (diagnostic_info , str (cm .exception .message_with_context ()))
726
726
727
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
727
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
728
728
def test_direct_results_uses_display_message_if_available (self , tcli_service_class ):
729
729
tcli_service_instance = tcli_service_class .return_value
730
730
@@ -825,7 +825,7 @@ def test_handle_execute_response_checks_direct_results_for_error_statuses(self):
825
825
thrift_backend ._handle_execute_response (error_resp , Mock ())
826
826
self .assertIn ("this is a bad error" , str (cm .exception ))
827
827
828
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
828
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
829
829
def test_handle_execute_response_can_handle_without_direct_results (
830
830
self , tcli_service_class
831
831
):
@@ -917,7 +917,7 @@ def test_handle_execute_response_can_handle_with_direct_results(self):
917
917
ttypes .TOperationState .FINISHED_STATE ,
918
918
)
919
919
920
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
920
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
921
921
def test_use_arrow_schema_if_available (self , tcli_service_class ):
922
922
tcli_service_instance = tcli_service_class .return_value
923
923
arrow_schema_mock = MagicMock (name = "Arrow schema mock" )
@@ -946,7 +946,7 @@ def test_use_arrow_schema_if_available(self, tcli_service_class):
946
946
947
947
self .assertEqual (execute_response .arrow_schema_bytes , arrow_schema_mock )
948
948
949
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
949
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
950
950
def test_fall_back_to_hive_schema_if_no_arrow_schema (self , tcli_service_class ):
951
951
tcli_service_instance = tcli_service_class .return_value
952
952
hive_schema_mock = MagicMock (name = "Hive schema mock" )
@@ -976,7 +976,7 @@ def test_fall_back_to_hive_schema_if_no_arrow_schema(self, tcli_service_class):
976
976
@patch (
977
977
"databricks.sql.utils.ResultSetQueueFactory.build_queue" , return_value = Mock ()
978
978
)
979
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
979
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
980
980
def test_handle_execute_response_reads_has_more_rows_in_direct_results (
981
981
self , tcli_service_class , build_queue
982
982
):
@@ -1020,7 +1020,7 @@ def test_handle_execute_response_reads_has_more_rows_in_direct_results(
1020
1020
@patch (
1021
1021
"databricks.sql.utils.ResultSetQueueFactory.build_queue" , return_value = Mock ()
1022
1022
)
1023
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1023
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1024
1024
def test_handle_execute_response_reads_has_more_rows_in_result_response (
1025
1025
self , tcli_service_class , build_queue
1026
1026
):
@@ -1075,7 +1075,7 @@ def test_handle_execute_response_reads_has_more_rows_in_result_response(
1075
1075
1076
1076
self .assertEqual (has_more_rows , has_more_rows_resp )
1077
1077
1078
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1078
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1079
1079
def test_arrow_batches_row_count_are_respected (self , tcli_service_class ):
1080
1080
# make some semi-real arrow batches and check the number of rows is correct in the queue
1081
1081
tcli_service_instance = tcli_service_class .return_value
@@ -1128,7 +1128,7 @@ def test_arrow_batches_row_count_are_respected(self, tcli_service_class):
1128
1128
1129
1129
self .assertEqual (arrow_queue .n_valid_rows , 15 * 10 )
1130
1130
1131
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1131
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1132
1132
def test_execute_statement_calls_client_and_handle_execute_response (
1133
1133
self , tcli_service_class
1134
1134
):
@@ -1157,7 +1157,7 @@ def test_execute_statement_calls_client_and_handle_execute_response(
1157
1157
response , cursor_mock
1158
1158
)
1159
1159
1160
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1160
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1161
1161
def test_get_catalogs_calls_client_and_handle_execute_response (
1162
1162
self , tcli_service_class
1163
1163
):
@@ -1185,7 +1185,7 @@ def test_get_catalogs_calls_client_and_handle_execute_response(
1185
1185
response , cursor_mock
1186
1186
)
1187
1187
1188
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1188
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1189
1189
def test_get_schemas_calls_client_and_handle_execute_response (
1190
1190
self , tcli_service_class
1191
1191
):
@@ -1222,7 +1222,7 @@ def test_get_schemas_calls_client_and_handle_execute_response(
1222
1222
response , cursor_mock
1223
1223
)
1224
1224
1225
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1225
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1226
1226
def test_get_tables_calls_client_and_handle_execute_response (
1227
1227
self , tcli_service_class
1228
1228
):
@@ -1263,7 +1263,7 @@ def test_get_tables_calls_client_and_handle_execute_response(
1263
1263
response , cursor_mock
1264
1264
)
1265
1265
1266
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1266
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1267
1267
def test_get_columns_calls_client_and_handle_execute_response (
1268
1268
self , tcli_service_class
1269
1269
):
@@ -1304,7 +1304,7 @@ def test_get_columns_calls_client_and_handle_execute_response(
1304
1304
response , cursor_mock
1305
1305
)
1306
1306
1307
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1307
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1308
1308
def test_open_session_user_provided_session_id_optional (self , tcli_service_class ):
1309
1309
tcli_service_instance = tcli_service_class .return_value
1310
1310
tcli_service_instance .OpenSession .return_value = self .open_session_resp
@@ -1320,7 +1320,7 @@ def test_open_session_user_provided_session_id_optional(self, tcli_service_class
1320
1320
thrift_backend .open_session ({}, None , None )
1321
1321
self .assertEqual (len (tcli_service_instance .OpenSession .call_args_list ), 1 )
1322
1322
1323
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1323
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1324
1324
def test_op_handle_respected_in_close_command (self , tcli_service_class ):
1325
1325
tcli_service_instance = tcli_service_class .return_value
1326
1326
thrift_backend = ThriftDatabricksClient (
@@ -1337,7 +1337,7 @@ def test_op_handle_respected_in_close_command(self, tcli_service_class):
1337
1337
self .operation_handle ,
1338
1338
)
1339
1339
1340
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1340
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1341
1341
def test_session_handle_respected_in_close_session (self , tcli_service_class ):
1342
1342
tcli_service_instance = tcli_service_class .return_value
1343
1343
thrift_backend = ThriftDatabricksClient (
@@ -1354,7 +1354,7 @@ def test_session_handle_respected_in_close_session(self, tcli_service_class):
1354
1354
self .session_handle ,
1355
1355
)
1356
1356
1357
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1357
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1358
1358
def test_non_arrow_non_column_based_set_triggers_exception (
1359
1359
self , tcli_service_class
1360
1360
):
@@ -1403,8 +1403,8 @@ def test_create_arrow_table_raises_error_for_unsupported_type(self):
1403
1403
with self .assertRaises (OperationalError ):
1404
1404
thrift_backend ._create_arrow_table (t_row_set , Mock (), None , Mock ())
1405
1405
1406
- @patch ("databricks.sql.thrift_backend.convert_arrow_based_set_to_arrow_table" )
1407
- @patch ("databricks.sql.thrift_backend.convert_column_based_set_to_arrow_table" )
1406
+ @patch ("databricks.sql.backend. thrift_backend.convert_arrow_based_set_to_arrow_table" )
1407
+ @patch ("databricks.sql.backend. thrift_backend.convert_column_based_set_to_arrow_table" )
1408
1408
def test_create_arrow_table_calls_correct_conversion_method (
1409
1409
self , convert_col_mock , convert_arrow_mock
1410
1410
):
@@ -1597,7 +1597,7 @@ def test_convert_column_based_set_to_arrow_table_uses_types_from_col_set(self):
1597
1597
self .assertEqual (arrow_table .column (2 ).to_pylist (), [1.15 , 2.2 , 3.3 ])
1598
1598
self .assertEqual (arrow_table .column (3 ).to_pylist (), [b"\x11 " , b"\x22 " , b"\x33 " ])
1599
1599
1600
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1600
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1601
1601
def test_cancel_command_uses_active_op_handle (self , tcli_service_class ):
1602
1602
tcli_service_instance = tcli_service_class .return_value
1603
1603
@@ -1627,7 +1627,7 @@ def test_handle_execute_response_sets_active_op_handle(self):
1627
1627
"databricks.sql.thrift_api.TCLIService.TCLIService.Client.GetOperationStatus"
1628
1628
)
1629
1629
@patch (
1630
- "databricks.sql.thrift_backend._retry_policy" , new_callable = retry_policy_factory
1630
+ "databricks.sql.backend. thrift_backend._retry_policy" , new_callable = retry_policy_factory
1631
1631
)
1632
1632
def test_make_request_will_retry_GetOperationStatus (
1633
1633
self , mock_retry_policy , mock_GetOperationStatus , t_transport_class
@@ -1681,7 +1681,7 @@ def test_make_request_will_retry_GetOperationStatus(
1681
1681
)
1682
1682
1683
1683
with self .assertLogs (
1684
- "databricks.sql.thrift_backend" , level = logging .WARNING
1684
+ "databricks.sql.backend. thrift_backend" , level = logging .WARNING
1685
1685
) as cm :
1686
1686
with self .assertRaises (RequestError ):
1687
1687
thrift_backend .make_request (client .GetOperationStatus , req )
@@ -1702,7 +1702,7 @@ def test_make_request_will_retry_GetOperationStatus(
1702
1702
"databricks.sql.thrift_api.TCLIService.TCLIService.Client.GetOperationStatus"
1703
1703
)
1704
1704
@patch (
1705
- "databricks.sql.thrift_backend._retry_policy" , new_callable = retry_policy_factory
1705
+ "databricks.sql.backend. thrift_backend._retry_policy" , new_callable = retry_policy_factory
1706
1706
)
1707
1707
def test_make_request_will_retry_GetOperationStatus_for_http_error (
1708
1708
self , mock_retry_policy , mock_gos
@@ -1779,7 +1779,7 @@ def test_make_request_wont_retry_if_error_code_not_429_or_503(
1779
1779
1780
1780
@patch ("databricks.sql.auth.thrift_http_client.THttpClient" )
1781
1781
@patch (
1782
- "databricks.sql.thrift_backend._retry_policy" , new_callable = retry_policy_factory
1782
+ "databricks.sql.backend. thrift_backend._retry_policy" , new_callable = retry_policy_factory
1783
1783
)
1784
1784
def test_make_request_will_retry_stop_after_attempts_count_if_retryable (
1785
1785
self , mock_retry_policy , t_transport_class
@@ -1959,7 +1959,7 @@ def test_retry_args_passthrough(self, mock_http_client):
1959
1959
@patch ("thrift.transport.THttpClient.THttpClient" )
1960
1960
def test_retry_args_bounding (self , mock_http_client ):
1961
1961
retry_delay_test_args_and_expected_values = {}
1962
- for k , (_ , _ , min , max ) in databricks .sql .thrift_backend ._retry_policy .items ():
1962
+ for k , (_ , _ , min , max ) in databricks .sql .backend . thrift_backend ._retry_policy .items ():
1963
1963
retry_delay_test_args_and_expected_values [k ] = (
1964
1964
(min - 1 , min ),
1965
1965
(max + 1 , max ),
@@ -1986,7 +1986,7 @@ def test_retry_args_bounding(self, mock_http_client):
1986
1986
for arg , val in retry_delay_expected_vals .items ():
1987
1987
self .assertEqual (getattr (backend , arg ), val )
1988
1988
1989
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
1989
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
1990
1990
def test_configuration_passthrough (self , tcli_client_class ):
1991
1991
tcli_service_instance = tcli_client_class .return_value
1992
1992
tcli_service_instance .OpenSession .return_value = self .open_session_resp
@@ -2011,7 +2011,7 @@ def test_configuration_passthrough(self, tcli_client_class):
2011
2011
open_session_req = tcli_client_class .return_value .OpenSession .call_args [0 ][0 ]
2012
2012
self .assertEqual (open_session_req .configuration , expected_config )
2013
2013
2014
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
2014
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
2015
2015
def test_cant_set_timestamp_as_string_to_true (self , tcli_client_class ):
2016
2016
tcli_service_instance = tcli_client_class .return_value
2017
2017
tcli_service_instance .OpenSession .return_value = self .open_session_resp
@@ -2038,7 +2038,7 @@ def _construct_open_session_with_namespace(self, can_use_multiple_cats, cat, sch
2038
2038
initialNamespace = ttypes .TNamespace (catalogName = cat , schemaName = schem ),
2039
2039
)
2040
2040
2041
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
2041
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
2042
2042
def test_initial_namespace_passthrough_to_open_session (self , tcli_client_class ):
2043
2043
tcli_service_instance = tcli_client_class .return_value
2044
2044
@@ -2066,7 +2066,7 @@ def test_initial_namespace_passthrough_to_open_session(self, tcli_client_class):
2066
2066
self .assertEqual (open_session_req .initialNamespace .catalogName , cat )
2067
2067
self .assertEqual (open_session_req .initialNamespace .schemaName , schem )
2068
2068
2069
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
2069
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
2070
2070
def test_can_use_multiple_catalogs_is_set_in_open_session_req (
2071
2071
self , tcli_client_class
2072
2072
):
@@ -2086,7 +2086,7 @@ def test_can_use_multiple_catalogs_is_set_in_open_session_req(
2086
2086
open_session_req = tcli_client_class .return_value .OpenSession .call_args [0 ][0 ]
2087
2087
self .assertTrue (open_session_req .canUseMultipleCatalogs )
2088
2088
2089
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
2089
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
2090
2090
def test_can_use_multiple_catalogs_is_false_fails_with_initial_catalog (
2091
2091
self , tcli_client_class
2092
2092
):
@@ -2126,7 +2126,7 @@ def test_can_use_multiple_catalogs_is_false_fails_with_initial_catalog(
2126
2126
)
2127
2127
backend .open_session ({}, cat , schem )
2128
2128
2129
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
2129
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
2130
2130
def test_protocol_v3_fails_if_initial_namespace_set (self , tcli_client_class ):
2131
2131
tcli_service_instance = tcli_client_class .return_value
2132
2132
@@ -2154,8 +2154,8 @@ def test_protocol_v3_fails_if_initial_namespace_set(self, tcli_client_class):
2154
2154
str (cm .exception ),
2155
2155
)
2156
2156
2157
- @patch ("databricks.sql.thrift_backend.TCLIService.Client" , autospec = True )
2158
- @patch ("databricks.sql.thrift_backend.ThriftDatabricksClient._handle_execute_response" )
2157
+ @patch ("databricks.sql.backend. thrift_backend.TCLIService.Client" , autospec = True )
2158
+ @patch ("databricks.sql.backend. thrift_backend.ThriftDatabricksClient._handle_execute_response" )
2159
2159
def test_execute_command_sets_complex_type_fields_correctly (
2160
2160
self , mock_handle_execute_response , tcli_service_class
2161
2161
):
0 commit comments