Skip to content

fix: use kLegacyPartitionDataIdStart as partition field ID baseline#832

Open
WZhuo wants to merge 1 commit into
apache:mainfrom
WZhuo:fix_part_field_id
Open

fix: use kLegacyPartitionDataIdStart as partition field ID baseline#832
WZhuo wants to merge 1 commit into
apache:mainfrom
WZhuo:fix_part_field_id

Conversation

@WZhuo

@WZhuo WZhuo commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

FreshPartitionSpec and TableMetadataBuilder::Impl both initialized the
partition field ID counter to kInvalidPartitionFieldId (-1), causing
the first partition field to get ID 0 instead of 1000. Partition field
ID 0 collides with ManifestEntry internal fields:

Field ID
ManifestEntry.status 0
ManifestEntry.snapshot_id 1
ManifestEntry.data_file 2

This corrupts manifest file schemas during serialization and breaks
partition pruning.

Fix

Change both initializers to kLegacyPartitionDataIdStart - 1 (999),
consistent with Java Iceberg's PARTITION_DATA_ID_START convention and
the rest of the C++ codebase (PartitionSpec constructor,
Unpartitioned(), UpdatePartitionSpec). The first partition field
now correctly gets ID 1000.

Location Before After
FreshPartitionSpec counter -1 999
TableMetadataBuilder::Impl::last_partition_id -1 999
First partition field ID 0 1000

FreshPartitionSpec and TableMetadataBuilder::Impl both initialized the
partition field ID counter to kInvalidPartitionFieldId (-1), causing
the first partition field to get ID 0 instead of 1000. Partition field
ID 0 collides with ManifestEntry internal fields (status=0,
snapshot_id=1, data_file=2), corrupting manifest file schemas.

Fix by using kLegacyPartitionDataIdStart - 1 (999) as the baseline,
consistent with PartitionSpec's own constructor, Unpartitioned(), and
UpdatePartitionSpec, as well as Java Iceberg's PARTITION_DATA_ID_START
convention. The first partition field now correctly gets ID 1000.
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.

2 participants