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
panic: GROUP BY or SELECT DISTINCT over a zero-field (empty) struct key #25281
GROUP BY (and SELECT DISTINCT) over a group key whose type contains a zero-field struct (DataType::Struct(Fields::empty())) panics when the aggregate emits.
A zero-field struct array has no child to derive its length from, so arrow-rs refuses StructArray::try_new for it. The group-value emit path rebuilds the key column with that constructor and unwraps the resulting error.
To Reproduce
$ datafusion-cli -c "select arrow_cast(null, 'Struct()') as s, count(*) from (values (1),(2),(3)) group by 1;"DataFusion CLI v55.1.0thread 'tokio-rt-worker' panicked at datafusion/physical-plan/src/aggregates/group_values/multi_group_by/row_backed.rs:225:14:dictionary re-encode during emit: ArrowError(InvalidArgumentError("use StructArray::try_new_with_length or StructArray::new_empty_fields to create a struct array with no fields so that the length can be set correctly"), Some(""))Error: Join Errorcaused byExternal error: task 63 panicked with message "dictionary re-encode during emit: ..."
Same panic for SELECT DISTINCT:
select distinct arrow_cast(null, 'Struct()') as s from (values (1),(2));
and when the zero-field struct is nested inside the key rather than being the whole key:
select named_struct('a', column1, 'z', arrow_cast(null, 'Struct()')) as s, count(*)
from (values (1),(2)) group by1;
Expected behavior
The query returns its groups. A zero-field struct is a valid Arrow type and carries one bit per row (null or not), so it should group like any other key.
Activity
fix: support zero-field struct group keys in aggregate emit (apache#2…
fix: support zero-field struct group keys in aggregate emit (apache#2…