Uh oh!
There was an error while loading. Please reload this page.
fix(common): support empty struct in ScalarValue::compact and new_default - #24582
Conversation
| Arc::new(StructArray::new_empty_fields( | ||
| s.len(), | ||
| s.nulls().cloned(), | ||
| )) |
There was a problem hiding this comment.
could probably clone the input instead of reconstructing?
| let nulls = NullBuffer::from(vec![true, false, true]); | ||
| let empty_struct = Arc::new(StructArray::new_empty_fields(3, Some(nulls))); | ||
| let mut scalar = ScalarValue::Struct(empty_struct); | ||
| // Before fix: panics inside compact_view_buffers calling StructArray::new on 0 fields | ||
| scalar.compact(); |
There was a problem hiding this comment.
seems a bit odd that a scalar would have 3 rows
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #24582 +/- ##
==========================================
+ Coverage 81.38% 81.42% +0.04%
==========================================
Files 1116 1121 +5 Lines 397960 402202 +4242 Branches 397960 402202 +4242 ==========================================
+ Hits 323880 327502 +3622 - Misses 55120 55498 +378 - Partials 18960 19202 +242 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Thanks @Jefffrey! Empty struct handling: Since zero-field structs don't have child buffers to compact, compact_view_buffers now just returns the input array directly. Test update: Switched test_compact_empty_struct from the 3-row scalar to a single-row StructArray (kept a null row so we still verify null buffer handling). CI: Fixed the cargo fmt issue in the new nested test. |
Jefffrey
commented
Aug 30, 2026
thanks @unikdahal |
Uh oh!
There was an error while loading. Please reload this page.
Which issue does this PR close?
Closes#24581.
Rationale for this change
StructArray::newpanics for structs with zero fields because it cannot infer array length from an empty column list. This hit two code paths inScalarValue:new_defaultwhen building a default value for a zero-field struct type, andcompact_view_buffers(used byScalarValue::compact) when compacting a struct array that has zero fields but a nonzero row count.What changes are included in this PR?
ScalarValue::new_defaultandcompact_view_buffersnow special-case zero-field structs, usingStructArray::new_empty_fields(which takes an explicit length/nulls instead of inferring it from columns) rather thanStructArray::new.test_compact_empty_structcovering the panic case.Are these changes tested?
Yes, new unit test added.
Are there any user-facing changes?
No behavior change other than fixing a panic on empty-field structs.