@@ -207,6 +207,38 @@ def test_remove_identity_v2(catalog: Catalog) -> None:
207207 assert table_v2 .spec () == PartitionSpec (spec_id = 0 )
208208
209209
210+ @pytest .mark .integration
211+ @pytest .mark .parametrize ("catalog" , [pytest .lazy_fixture ("session_catalog_hive" ), pytest .lazy_fixture ("session_catalog" )])
212+ def test_remove_and_add_identity (catalog : Catalog ) -> None :
213+ table = _table (catalog )
214+ table .update_spec ().add_identity ("id" ).commit ()
215+ table .update_spec ().remove_field ("id" ).commit ()
216+ table .update_spec ().add_identity ("id" ).commit ()
217+
218+ assert len (table .specs ()) == 4
219+ assert table .spec ().spec_id == 3
220+ assert table .spec () == PartitionSpec (
221+ PartitionField (source_id = 1 , field_id = 1000 , transform = VoidTransform (), name = "id_1000" ),
222+ PartitionField (source_id = 1 , field_id = 1001 , transform = IdentityTransform (), name = "id" ),
223+ spec_id = 3 ,
224+ )
225+
226+
227+ @pytest .mark .integration
228+ @pytest .mark .parametrize ("catalog" , [pytest .lazy_fixture ("session_catalog_hive" ), pytest .lazy_fixture ("session_catalog" )])
229+ def test_remove_and_add_identity_v2 (catalog : Catalog ) -> None :
230+ table_v2 = _table_v2 (catalog )
231+ table_v2 .update_spec ().add_identity ("id" ).commit ()
232+ table_v2 .update_spec ().remove_field ("id" ).commit ()
233+ table_v2 .update_spec ().add_identity ("id" ).commit ()
234+
235+ assert len (table_v2 .specs ()) == 2
236+ assert table_v2 .spec ().spec_id == 1
237+ assert table_v2 .spec () == PartitionSpec (
238+ PartitionField (source_id = 1 , field_id = 1000 , transform = IdentityTransform (), name = "id" ), spec_id = 1
239+ )
240+
241+
210242@pytest .mark .integration
211243@pytest .mark .parametrize ("catalog" , [pytest .lazy_fixture ("session_catalog_hive" ), pytest .lazy_fixture ("session_catalog" )])
212244def test_remove_bucket (catalog : Catalog ) -> None :
0 commit comments