fix: handle Null type in try_merge for Struct, List, LargeList, and Union#9524
Open
zhuqi-lucas wants to merge 1 commit intoapache:mainfrom
Open
fix: handle Null type in try_merge for Struct, List, LargeList, and Union#9524zhuqi-lucas wants to merge 1 commit intoapache:mainfrom
zhuqi-lucas wants to merge 1 commit intoapache:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Field::try_merge to treat DataType::Null as compatible when merging into compound field types (Struct, Union, List, LargeList), preventing schema-merge failures common during JSON schema inference.
Changes:
- Add
DataType::Nullmatch arms for Struct/Union/List/LargeList inField::try_mergeto mark the field nullable instead of erroring - Add a regression test covering merges of compound types with
Null
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Contributor
Author
|
cc @alamb , i met some corner cases when using infer schema, and i found it's the bug from arrow side. I hope this PR is helpful, thanks! error: Error: Arrow error: Schema error: Fail to merge schema field 'item' because the from data_type = Null is not DataType::Struct |
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.
Which issue does this PR close?
Field::try_merge correctly handles DataType::Null for primitive types
and when self is Null, but fails when self is a compound type (Struct,
List, LargeList, Union) and from is Null. This causes Schema::try_merge
to error when merging schemas where one has a Null field and another has a
concrete compound type for the same field.
This is common in JSON inference where some files have null values for
fields that are structs/lists in other files.
Rationale for this change
Add
DataType::Nullarms to the Struct, List, LargeList, and Unionbranches in
Field::try_merge, consistent with how primitive typesalready handle it.
What changes are included in this PR?
Add
DataType::Nullarms to the Struct, List, LargeList, and Unionbranches in
Field::try_merge, consistent with how primitive typesalready handle it.
Are these changes tested?
test_merge_compound_with_nullcovering Struct, List,LargeList, and Union merging with Null in both directions.
Are there any user-facing changes?
No