You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GH-55682: [C++][Parquet] Fix non-nullable list inside null ancestor - #55704
A struct can be null while a fixed-size list field underneath it is declared non-nullable in the schema. In that case the list keeps no validity information of its own, so nothing records that the struct's null row left no physical values behind for it. Reading such a column back raises "Expected all lists to be of size=N but index M had size=0" even though the file is well-formed. This follows on from GH-35692, which fixed the same symptom for the case where the list field itself carries the null.
What changes are included in this PR?
The reader decided whether to pad a missing fixed-size list slot based on whether the list had its own null count, which is always zero for a non-nullable field regardless of what its ancestor did. The fix instead looks at the decoded element offsets directly: a null ancestor still leaves a zero-length span where a full list was expected, and that gap is now detected and padded the same way as a list that is null in its own right.
Are these changes tested?
Yes, with a new regression test reproducing the reported schema (a nullable struct holding a non-nullable fixed-size list field):
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The change silently converts present empty lists into null-filled fixed-size lists instead of rejecting size mismatches, while also adding unnecessary child-buffer allocations and copies to ordinary reads.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The nullable-field guard silently pads present empty required lists with nulls instead of rejecting size mismatches, without distinguishing them from absent ancestors.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The definition-level guard can silently accept invalid nested fixed-size lists, converting a present empty size-2 list into [null, null] instead of rejecting the size mismatch.
For a REQUIRED size-2 list beneath an OPTIONAL struct that is present, [1, 2], [], [3, 4] produces offsets [0, 2, 2, 4] and passes def_level > rep_level. This code silently turns the visible empty list into [null, null] instead of rejecting the size mismatch; an optional outer list can also satisfy the guard without supplying a missing inner slot. Use each slot's definition level, accounting for the closest repeated ancestor, to distinguish absent ancestors from present empty lists, and add rejection regressions for these nested schemas.
…stor
The reader only padded a null fixed-size list slot when the list's own
null count was nonzero, but a non-nullable list never has a validity
bitmap. A null struct ancestor leaves no child values written for that
row, and nothing recorded the gap. Detect it from the offsets directly:
a zero-length span where list_size was expected is padded the same way
an own-null run already is.
Signed-off-by: 1fanwang <1fannnw@gmail.com>
A batch paid for a rebuild even with no gaps. A nullable field with
zero nulls could pad a physically empty list instead of rejecting it,
since its validity buffer is discarded whenever null count is zero,
regardless of nullability.
Branch on field()->nullable() instead: scan offsets for gaps only
when non-nullable, since zero nulls on a nullable field already means
no gap exists.
Signed-off-by: 1fanwang <1fannnw@gmail.com>
A non-nullable field has no validity buffer regardless of ancestor
nullability, so the gap scan could not tell a null struct ancestor
from a corrupt present-but-empty list under a bare REQUIRED list.
Every repeated step raises def_level and rep_level equally, so
def_level > rep_level means an ancestor is optional. Scan for gaps
only then; otherwise reject any gap as corrupt.
Signed-off-by: 1fanwang <1fannnw@gmail.com>
An absent ancestor and a corruptly empty required list under a
present struct collapse to the same zero-length offset span, and a
non-nullable field has no validity buffer to tell them apart.
BuildArray always computes the per-slot bitmap from definition
levels, which does distinguish them, clearing it for a non-nullable
result. Added a required-list-under-present-struct regression.
Signed-off-by: 1fanwang <1fannnw@gmail.com>
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
No active review issues are recorded for the fixed-size-list read fix.
No open issues 🎉
Review effort: Balanced
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
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
A struct can be null while a fixed-size list field underneath it is declared non-nullable in the schema. In that case the list keeps no validity information of its own, so nothing records that the struct's null row left no physical values behind for it. Reading such a column back raises "Expected all lists to be of size=N but index M had size=0" even though the file is well-formed. This follows on from GH-35692, which fixed the same symptom for the case where the list field itself carries the null.
What changes are included in this PR?
The reader decided whether to pad a missing fixed-size list slot based on whether the list had its own null count, which is always zero for a non-nullable field regardless of what its ancestor did. The fix instead looks at the decoded element offsets directly: a null ancestor still leaves a zero-length span where a full list was expected, and that gap is now detected and padded the same way as a list that is null in its own right.
Are these changes tested?
Yes, with a new regression test reproducing the reported schema (a nullable struct holding a non-nullable fixed-size list field):
Before the fix, this fails with the exact reported error:
After the fix it passes, and the roundtripped table decodes the null struct row's fixed-size list as nulls instead of erroring:
Are there any user-facing changes?
No API changes; this fixes a read failure on previously-unreadable but well-formed files.
Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
PR code and description written by:
Reviewed before submission by: