39
39
SerDeInfo ,
40
40
SkewedInfo ,
41
41
StorageDescriptor ,
42
+ )
43
+ from hive_metastore .v4 .ttypes import (
42
44
Database as HiveDatabase ,
45
+ )
46
+ from hive_metastore .v4 .ttypes import (
43
47
Table as HiveTable ,
44
48
)
45
49
@@ -254,8 +258,7 @@ def test_no_uri_supplied() -> None:
254
258
255
259
256
260
def test_check_number_of_namespaces (table_schema_simple : Schema ) -> None :
257
- _HiveClient ._get_hive_version = MagicMock ()
258
- _HiveClient ._get_hive_version .return_value = 3
261
+ _HiveClient ._get_hive_version = MagicMock (return_value = 3 ) # type: ignore
259
262
catalog = HiveCatalog (HIVE_CATALOG_NAME , uri = HIVE_METASTORE_FAKE_URL )
260
263
261
264
with pytest .raises (ValueError ):
@@ -282,8 +285,7 @@ def test_create_table(
282
285
283
286
catalog ._client = MagicMock ()
284
287
catalog ._client .__enter__ ().create_table .return_value = None
285
- catalog ._get_hive_table = MagicMock ()
286
- catalog ._get_hive_table .return_value = hive_table
288
+ catalog ._get_hive_table = MagicMock (return_value = hive_table ) # type: ignore
287
289
catalog ._client .__enter__ ().get_database .return_value = hive_database
288
290
catalog .create_table (("default" , "table" ), schema = table_schema_with_all_types , properties = {"owner" : "javaberg" })
289
291
@@ -462,8 +464,7 @@ def test_create_table_with_given_location_removes_trailing_slash(
462
464
463
465
catalog ._client = MagicMock ()
464
466
catalog ._client .__enter__ ().create_table .return_value = None
465
- catalog ._get_hive_table = MagicMock ()
466
- catalog ._get_hive_table .return_value = hive_table
467
+ catalog ._get_hive_table = MagicMock (return_value = hive_table ) # type: ignore
467
468
catalog ._client .__enter__ ().get_database .return_value = hive_database
468
469
catalog .create_table (
469
470
("default" , "table" ), schema = table_schema_with_all_types , properties = {"owner" : "javaberg" }, location = f"{ location } /"
@@ -636,7 +637,7 @@ def test_create_v1_table(table_schema_simple: Schema, hive_database: HiveDatabas
636
637
catalog = HiveCatalog (HIVE_CATALOG_NAME , uri = HIVE_METASTORE_FAKE_URL )
637
638
638
639
catalog ._client = MagicMock ()
639
- catalog ._get_hive_table = MagicMock ()
640
+ catalog ._get_hive_table = MagicMock () # type: ignore
640
641
catalog ._client .__enter__ ().create_table .return_value = None
641
642
catalog ._get_hive_table .return_value = hive_table
642
643
catalog ._client .__enter__ ().get_database .return_value = hive_database
@@ -689,8 +690,7 @@ def test_load_table(hive_table: HiveTable) -> None:
689
690
catalog = HiveCatalog (HIVE_CATALOG_NAME , uri = HIVE_METASTORE_FAKE_URL )
690
691
691
692
catalog ._client = MagicMock ()
692
- catalog ._get_hive_table = MagicMock ()
693
- catalog ._get_hive_table .return_value = hive_table
693
+ catalog ._get_hive_table = MagicMock (return_value = hive_table ) # type: ignore
694
694
table = catalog .load_table (("default" , "new_tabl2e" ))
695
695
696
696
catalog ._get_hive_table .assert_called_with (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl2e" )
@@ -790,8 +790,7 @@ def test_load_table_from_self_identifier(hive_table: HiveTable) -> None:
790
790
catalog = HiveCatalog (HIVE_CATALOG_NAME , uri = HIVE_METASTORE_FAKE_URL )
791
791
792
792
catalog ._client = MagicMock ()
793
- catalog ._get_hive_table = MagicMock ()
794
- catalog ._get_hive_table .return_value = hive_table
793
+ catalog ._get_hive_table = MagicMock (return_value = hive_table ) # type: ignore
795
794
intermediate = catalog .load_table (("default" , "new_tabl2e" ))
796
795
table = catalog .load_table (intermediate .name ())
797
796
@@ -896,8 +895,7 @@ def test_rename_table(hive_table: HiveTable) -> None:
896
895
renamed_table .tableName = "new_tabl3e"
897
896
898
897
catalog ._client = MagicMock ()
899
- catalog ._get_hive_table = MagicMock ()
900
- catalog ._get_hive_table .side_effect = [hive_table , renamed_table ]
898
+ catalog ._get_hive_table = MagicMock (side_effect = [hive_table , renamed_table ]) # type: ignore
901
899
catalog ._client .__enter__ ().alter_table_with_environment_context .return_value = None
902
900
903
901
from_identifier = ("default" , "new_tabl2e" )
@@ -906,7 +904,10 @@ def test_rename_table(hive_table: HiveTable) -> None:
906
904
907
905
assert table .name () == to_identifier
908
906
909
- calls = [call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl2e" ), call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl3e" )]
907
+ calls = [
908
+ call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl2e" ),
909
+ call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl3e" ),
910
+ ]
910
911
catalog ._get_hive_table .assert_has_calls (calls )
911
912
catalog ._client .__enter__ ().alter_table_with_environment_context .assert_called_with (
912
913
dbname = "default" ,
@@ -920,8 +921,7 @@ def test_rename_table_from_self_identifier(hive_table: HiveTable) -> None:
920
921
catalog = HiveCatalog (HIVE_CATALOG_NAME , uri = HIVE_METASTORE_FAKE_URL )
921
922
922
923
catalog ._client = MagicMock ()
923
- catalog ._get_hive_table = MagicMock ()
924
- catalog ._get_hive_table .return_value = hive_table
924
+ catalog ._get_hive_table = MagicMock (return_value = hive_table ) # type: ignore
925
925
926
926
from_identifier = ("default" , "new_tabl2e" )
927
927
from_table = catalog .load_table (from_identifier )
@@ -938,7 +938,10 @@ def test_rename_table_from_self_identifier(hive_table: HiveTable) -> None:
938
938
939
939
assert table .name () == to_identifier
940
940
941
- calls = [call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl2e" ), call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl3e" )]
941
+ calls = [
942
+ call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl2e" ),
943
+ call (catalog ._client .__enter__ (), dbname = "default" , tbl_name = "new_tabl3e" ),
944
+ ]
942
945
catalog ._get_hive_table .assert_has_calls (calls )
943
946
catalog ._client .__enter__ ().alter_table_with_environment_context .assert_called_with (
944
947
dbname = "default" ,
@@ -1024,7 +1027,7 @@ def test_list_tables(hive_table: HiveTable) -> None:
1024
1027
1025
1028
catalog ._client = MagicMock ()
1026
1029
catalog ._client .__enter__ ().get_all_tables .return_value = ["table1" , "table2" , "table3" , "table4" ]
1027
- catalog ._get_table_objects_by_name = MagicMock ()
1030
+ catalog ._get_table_objects_by_name = MagicMock () # type: ignore
1028
1031
catalog ._get_table_objects_by_name .return_value = [tbl1 , tbl2 , tbl3 , tbl4 ]
1029
1032
1030
1033
got_tables = catalog .list_tables ("database" )
@@ -1061,8 +1064,7 @@ def test_drop_table_from_self_identifier(hive_table: HiveTable) -> None:
1061
1064
catalog = HiveCatalog (HIVE_CATALOG_NAME , uri = HIVE_METASTORE_FAKE_URL )
1062
1065
1063
1066
catalog ._client = MagicMock ()
1064
- catalog ._get_hive_table = MagicMock ()
1065
- catalog ._get_hive_table .return_value = hive_table
1067
+ catalog ._get_hive_table = MagicMock (return_value = hive_table ) # type: ignore
1066
1068
table = catalog .load_table (("default" , "new_tabl2e" ))
1067
1069
1068
1070
catalog ._client .__enter__ ().get_all_databases .return_value = ["namespace1" , "namespace2" ]
0 commit comments