Repository navigation
Map add_files columns by the file's own field IDs - #4359
Open
rahulsmahadev wants to merge 1 commit into
Open
rahulsmahadev wants to merge 1 commit into
rahulsmahadev wants to merge 1 commit into
Conversation
add_files matched each Parquet column path against the table's current names, so a renamed column or a list element named item failed with KeyError, and a reused name recorded statistics under the wrong field ID. The mapping now uses the file's own paths and field IDs, and a file column whose field ID the table lacks is rejected with the existing "more columns" ValueError. Co-authored-by: Isaac <no-reply@databricks.com>
Contributor
Author
|
@kevinjqliu @jeroko could you take a look when you have a chance? It builds on #2662 and keys |
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
add_fileslooks up each Parquet column path in a mapping built from the table's current column names, so a file that is valid for the table fails when its paths differ from those names:The same happens for a nested field renamed after the file was written (
KeyError: 'address.zip') and for a list whose element is nameditem, the layout pyarrow writes withuse_compliant_nested_type=False(KeyError: 'tags.list.item'). #716 reported the list case; the stale bot closed it without a fix.The name-based mapping can also record statistics under the wrong column. If the table drops
a(field ID 1) and adds a newa(field ID 3), an old file'sais recorded under field ID 3, so a scan fora IS NULLprunes the file and misses its rows.This change builds the mapping from the file's own column paths and field IDs (with name mapping for files without IDs), so statistics follow field IDs as they do for files PyIceberg writes.
Are these changes tested?
Yes, in
tests/io/test_pyarrow.py.test_add_files_matches_columns_by_field_idcovers the nested rename and theitemlist element with and without field IDs.test_add_files_rejects_columns_missing_from_tablecovers a file column whose field ID the table lacks and a column whose name matches but whose field ID differs. Both fail without this change.Are there any user-facing changes?
Yes:
add_filesaccepts files whose columns were renamed in the table and files whose list element is not namedelement.ValueErrorinstead of aKeyError.This pull request and its description were written by Isaac.