@@ -40,3 +40,35 @@ def test_create_branch(catalog: Catalog) -> None:
4040 branch_snapshot_id = tbl .history ()[- 2 ].snapshot_id
4141 tbl .manage_snapshots ().create_branch (snapshot_id = branch_snapshot_id , branch_name = "branch123" ).commit ()
4242 assert tbl .metadata .refs ["branch123" ] == SnapshotRef (snapshot_id = branch_snapshot_id , snapshot_ref_type = "branch" )
43+
44+
45+ @pytest .mark .integration
46+ @pytest .mark .parametrize ("catalog" , [pytest .lazy_fixture ("session_catalog_hive" ), pytest .lazy_fixture ("session_catalog" )])
47+ def test_remove_tag (catalog : Catalog ) -> None :
48+ identifier = "default.test_table_snapshot_operations"
49+ tbl = catalog .load_table (identifier )
50+ assert len (tbl .history ()) > 3
51+ # first, create the tag to remove
52+ tag_name = "tag_to_remove"
53+ tag_snapshot_id = tbl .history ()[- 3 ].snapshot_id
54+ tbl .manage_snapshots ().create_tag (snapshot_id = tag_snapshot_id , tag_name = tag_name ).commit ()
55+ assert tbl .metadata .refs [tag_name ] == SnapshotRef (snapshot_id = tag_snapshot_id , snapshot_ref_type = "tag" )
56+ # now, remove the tag
57+ tbl .manage_snapshots ().remove_tag (tag_name = tag_name ).commit ()
58+ assert tbl .metadata .refs .get (tag_name , None ) is None
59+
60+
61+ @pytest .mark .integration
62+ @pytest .mark .parametrize ("catalog" , [pytest .lazy_fixture ("session_catalog_hive" ), pytest .lazy_fixture ("session_catalog" )])
63+ def test_remove_branch (catalog : Catalog ) -> None :
64+ identifier = "default.test_table_snapshot_operations"
65+ tbl = catalog .load_table (identifier )
66+ assert len (tbl .history ()) > 2
67+ # first, create the branch to remove
68+ branch_name = "branch_to_remove"
69+ branch_snapshot_id = tbl .history ()[- 2 ].snapshot_id
70+ tbl .manage_snapshots ().create_branch (snapshot_id = branch_snapshot_id , branch_name = branch_name ).commit ()
71+ assert tbl .metadata .refs [branch_name ] == SnapshotRef (snapshot_id = branch_snapshot_id , snapshot_ref_type = "branch" )
72+ # now, remove the branch
73+ tbl .manage_snapshots ().remove_branch (branch_name = branch_name ).commit ()
74+ assert tbl .metadata .refs .get (branch_name , None ) is None
0 commit comments