Repository navigation
Conversation
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change preserving Iceberg field metadata in dictionary-enabled PyArrow scans.
No open issues 🎉
What changed in this PR
Preserves Iceberg field IDs in dictionary-enabled PyArrow batch scans so Parquet exports retain column identity without losing dictionary encoding.
Changes:
- Takes dictionary types from the first batch while preserving projected field metadata and nullability.
- Adds a regression assertion that dictionary-column metadata matches the projected schema.
| File | Description |
|---|---|
| tests/io/test_pyarrow.py | Asserts metadata is preserved for dictionary-encoded columns. |
| pyiceberg/table/__init__.py | Updates projected field types without replacing their metadata or nullability. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Requesting dictionary encoding on a streaming scan dropped the Iceberg field ID for that column. Saving the result to Parquet preserved the values but lost the column's identity. The same export without dictionary encoding kept the ID.
The reader now takes the dictionary type from the first batch and retains the field from the projected schema. The encoding fix in #3595 still applies.
Are these changes tested?
End-to-end testing
With the PyArrow and SQLite extras installed, run the reproducer from the checkout:
Before, the dictionary-enabled column could not be converted back to an Iceberg field. Output and final exception:
After:
Reproducer source: repro.py
Are there any user-facing changes?
Parquet exports from dictionary-enabled batch scans keep the same field IDs as plain scans.
AI disclosure: GitHub Copilot CLI drafted the fix and regression assertion.