Skip to content

Bug Fix: handle column projection edge case with null identity partition - #4083

Open
sungwy wants to merge 1 commit into
apache:mainfrom
sungwy:fix-null-identity-partition-default
Open

sungwy wants to merge 1 commit into
apache:mainfrom
sungwy:fix-null-identity-partition-default

Conversation

@sungwy

@sungwy sungwy commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Rationale for this change

The spec's Column Projection rules say that when a field isn't present in a data file, we resolve its value in order:

  1. the identity partition value from the manifest's partition struct, if present
  2. the column found via schema.name-mapping.default
  3. the field's initial-default
  4. null

Today _get_column_projection_values only records the identity partition value when it's non-null. So when a file's partition value is null, we skip rule 1 and fall through to rule 3, as if the partition metadata had nothing to say. This was harmless before v3 because initial-default was always null anyway, but with a non-null initial-default we now read the default instead of null.

This came up while reviewing #4082

Are these changes tested?

Yes

Are there any user-facing changes?

Only for v3 tables with a non-null initial-default on an identity-partitioned column on null partition. This is a bug fix that conforms to the spec: https://iceberg.apache.org/spec/#column-projection

Copilot AI balanced review requested due to automatic review settings October 6, 2026 21:37
@sungwy sungwy added the changelog Indicates that the PR introduces changes that require an entry in the changelog. label Oct 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Filter-only partition columns still fall back to the initial default when excluded from the output projection.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes null identity partition projection so it takes precedence over a field’s initial default.

Changes:

  • Preserves explicit null partition values during projection and filtering.
  • Adds regression coverage for null projection and predicates.
File Description
pyiceberg/​io/​pyarrow.py Distinguishes explicit null projections from absent values.
tests/​io/​test_pyarrow.py Tests null identity partitions with initial defaults.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pyiceberg/io/pyarrow.py
partition_value = accessors[partition_field.field_id].get(file.partition)
if partition_value is not None:
projected_missing_fields[field_id] = partition_value
projected_missing_fields[field_id] = accessors[partition_field.field_id].get(file.partition)

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

changelog Indicates that the PR introduces changes that require an entry in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants