test: cover the narrowing direction of cast_and_stamp_schema - #5285
Open
andygrove wants to merge 1 commit into
Open
test: cover the narrowing direction of cast_and_stamp_schema#5285andygrove wants to merge 1 commit into
andygrove wants to merge 1 commit into
Conversation
The doc on cast_and_stamp_schema claims that narrowing a nullable nested child to non-null is not silently lossy because arrow rejects unmasked nulls under a non-nullable field, but no test pinned that. Add one that stamps a nullable-child array against a non-null-declared schema both with and without a real null, so the flag alone does not decide the outcome.
parthchandra
approved these changes
Aug 7, 2026
parthchandra
left a comment
Contributor
There was a problem hiding this comment.
thanks for adding the test @andygrove
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?
Follow-up to review feedback on #5138: #5138 (comment)
Rationale for this change
The doc comment on
cast_and_stamp_schemaclaims that reconciliation follows the declared schema in both directions, and that narrowing a nullable nested child to non-null is not silently lossy because arrow'sStructArray::try_newrejects unmasked nulls under a non-nullable field. That claim was not covered by a test, so nothing would catch it if the narrowing direction ever started producing an array whose nullability flag misreports its own contents.What changes are included in this PR?
One test in
native/common/src/schema.rs,narrowing_a_child_errors_only_when_it_holds_a_null. It stamps aList(Struct(nullable Boolean))array against a schema declaring the child non-null, twice:c0.element.flagThe two cases together pin that the child's
nullableflag alone does not decide the outcome: the data does.No production code changes.
How are these changes tested?
cargo test -p datafusion-comet-common schema::(10 passed).