Skip to content

Assign sequential partition field ids when reading v1 metadata without them - #4354

Open
sohailshk wants to merge 1 commit into
apache:mainfrom
sohailshk:fix/v1-partition-field-id
Open

sohailshk wants to merge 1 commit into
apache:mainfrom
sohailshk:fix/v1-partition-field-id

Conversation

@sohailshk

Copy link
Copy Markdown
Contributor

Rationale for this change

In v1 table metadata the partition field ids were not tracked: the spec says they were "assigned sequentially in each spec starting at 1,000". A v1 partition-spec (or partition-specs entry) whose fields have no field-id currently fails to parse: a pydantic "Field required" error for one field, and TypeError: '>' not supported between instances of 'NoneType' and 'NoneType' for two or more, raised while computing last-partition-id.

TableMetadataV1.construct_partition_specs now assigns 1000, 1001, ... within each spec when none of its fields has an id, before computing last-partition-id. A spec that mixes fields with and without ids is rejected with Java's message ("Cannot parse spec with missing field IDs"), as in PartitionSpecParser.

Are these changes tested?

Yes, test_v1_partition_fields_without_field_id in tests/table/test_metadata.py (fails on main, passes here). Also ran tests/table, tests/test_serializers.py, tests/catalog/test_base.py and tests/catalog/test_sql.py.

Are there any user-facing changes?

Old v1 tables written without partition field ids can now be loaded.

…t them

In v1 the partition field ids were not tracked and were assigned sequentially from 1000 in each spec. A v1 partition spec whose fields have no field-id failed to parse, with a TypeError for two or more fields.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant