@@ -672,26 +672,29 @@ def test_existing_table_partition_names_unchanged(
672672 schema = iceberg_table_schema ,
673673 )
674674
675- # Manually add a partition field with old-style naming (same as column name)
675+ # Manually add an identity partition field with old-style naming (same as column name).
676+ # PyIceberg no longer allows transformed partition field names to conflict with
677+ # schema column names, but identity partitions using the source column name are still
678+ # valid legacy specs.
676679 with table .update_spec () as update :
677680 update .add_field (
678- source_column_name = "timestamp " ,
679- transform = transforms .HourTransform (),
680- partition_field_name = "timestamp " , # Old style: same as column name
681+ source_column_name = "category " ,
682+ transform = transforms .IdentityTransform (),
683+ partition_field_name = "category " , # Old style: same as column name
681684 )
682685
683686 table .refresh ()
684687 original_field_name = table .spec ().fields [0 ].name
685- assert original_field_name == "timestamp "
688+ assert original_field_name == "category "
686689
687690 # Now run update with no actual changes (same partition dimensions)
688691 table_slice = TableSlice (
689692 table = table_name ,
690693 schema = namespace ,
691694 partition_dimensions = [
692695 TablePartitionDimension (
693- "timestamp " ,
694- TimeWindow ( dt . datetime ( 2023 , 1 , 1 ), dt . datetime ( 2023 , 1 , 1 , 1 )) ,
696+ "category " ,
697+ [ "A" ] ,
695698 ),
696699 ],
697700 )
@@ -709,7 +712,7 @@ def test_existing_table_partition_names_unchanged(
709712 assert len (table .spec ().fields ) == 1
710713 assert (
711714 table .spec ().fields [0 ].name == original_field_name
712- ) # Should still be "timestamp "
715+ ) # Should still be "category "
713716
714717
715718def test_partition_field_naming_avoids_column_conflicts (
0 commit comments