You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "fornwall (via GitHub)" <gi...@apache.org> on 2026/09/13 23:40:01 UTC

[I] panic: GROUP BY or SELECT DISTINCT over a zero-field (empty) struct key [datafusion]

fornwall opened a new issue, #25281:
URL: https://github.com/apache/datafusion/issues/25281

   ### Describe the bug
   
   `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
   
   ```console
   $ datafusion-cli -c "select arrow_cast(null, 'Struct()') as s, count(*) from (values (1),(2),(3)) group by 1;"
   DataFusion CLI v55.1.0
   
   thread '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 Error
   caused by
   External error: task 63 panicked with message "dictionary re-encode during emit: ..."
   ```
   Same panic for `SELECT DISTINCT`:
   
   ```sql
   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:
   
   ```sql
   select named_struct('a', column1, 'z', arrow_cast(null, 'Struct()')) as s, count(*)
   from (values (1),(2)) group by 1;
   ```
   
   ### Expected behavior
   
   _No response_
   
   ### Additional context
   
   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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] panic: GROUP BY or SELECT DISTINCT over a zero-field (empty) struct key [datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 closed issue #25281: panic: GROUP BY or SELECT DISTINCT over a zero-field (empty) struct key
URL: https://github.com/apache/datafusion/issues/25281


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org