@@ -389,48 +389,6 @@ def test_deserialize_partition_field_multi_arg_requires_transform() -> None:
389389 PartitionField .model_validate_json (json_partition_spec )
390390
391391
392- def test_deserialize_partition_field_both_source_id_and_source_ids_multi_arg () -> None :
393- import json as json_lib
394-
395- from pyiceberg .transforms import UnknownTransform
396-
397- # a non-conformant writer emitted both keys; source-ids carries the arity, so it wins
398- json_partition_spec = (
399- """{"source-id": 9, "source-ids": [1, 2], "field-id": 1000, "transform": "bucket[4]", "name": "multi_bucket"}"""
400- )
401- field = PartitionField .model_validate_json (json_partition_spec )
402-
403- assert isinstance (field .transform , UnknownTransform )
404- assert field .source_id == 1
405- assert field .source_ids == [1 , 2 ]
406-
407- serialized = json_lib .loads (field .model_dump_json ())
408- assert serialized ["source-ids" ] == [1 , 2 ]
409- assert "source-id" not in serialized
410-
411-
412- def test_deserialize_partition_field_both_source_id_and_source_ids_single_arg () -> None :
413- import json as json_lib
414-
415- json_partition_spec = (
416- """{"source-id": 9, "source-ids": [1], "field-id": 1000, "transform": "truncate[19]", "name": "str_truncate"}"""
417- )
418- field = PartitionField .model_validate_json (json_partition_spec )
419-
420- assert field .source_id == 1
421- assert field .source_ids is None
422-
423- serialized = json_lib .loads (field .model_dump_json ())
424- assert serialized ["source-id" ] == 1
425- assert "source-ids" not in serialized
426-
427-
428- def test_deserialize_partition_field_empty_source_ids_rejected_next_to_source_id () -> None :
429- json_partition_spec = """{"source-id": 1, "source-ids": [], "field-id": 1000, "transform": "identity", "name": "x"}"""
430- with pytest .raises (Exception , match = "Empty source-ids is not allowed" ):
431- PartitionField .model_validate_json (json_partition_spec )
432-
433-
434392def test_partition_field_transform_arguments () -> None :
435393 single = PartitionField (source_id = 1 , field_id = 1000 , transform = TruncateTransform (width = 19 ), name = "str_truncate" )
436394 assert single .transform_arguments == [1 ]
0 commit comments