Conversation
`GROUP BY` / `SELECT DISTINCT` over a key containing a zero-field struct (`Struct()`) panicked when the aggregate emitted its groups. The row-format decode path rebuilt each struct column with `StructArray::try_new`, which arrow rejects for zero fields because it cannot infer the length from a child column. Use `StructArray::try_new_with_length`, passing the source array's length, so zero-field structs are rebuilt like any other struct. Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #25282 +/- ##
==========================================
- Coverage 81.90% 81.90% -0.01%
==========================================
Files 1134 1134
Lines 425200 425201 +1
Branches 425200 425201 +1
==========================================
- Hits 348268 348251 -17
- Misses 56291 56304 +13
- Partials 20641 20646 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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?
Closes #25281.
Rationale for this change
GROUP BYandSELECT DISTINCTover a group key whose type contains a zero-field struct (Struct()) panicked when the aggregate emitted:The same panic hit
SELECT DISTINCTand keys where the empty struct is nested inside another struct. A zero-field struct is a valid Arrow type and should group like any other key.What changes are included in this PR?
encode_array_if_necessaryingroup_values/row.rsrebuilt every struct column withStructArray::try_new, which arrow rejects for zero fields since there is no child column to derive the length from. It now usesStructArray::try_new_with_lengthwith the source array's length, so zero-field structs are rebuilt like any other struct. This function is shared byGroupValuesRowsand the row-backedGroupColumn, so both paths are covered.What is the testing strategy for this PR?
Three new
sqllogictestcases at the end ofstruct.slt(whole-key,DISTINCT, and nested insidenamed_struct). All three panicked before the fix and pass after it.Are there any user-facing changes?
No, other than the panic being fixed.