Describe the bug
Calling ScalarValue::compact() or ScalarValue::new_default() on a zero-field struct schema (DataType::Struct(Fields::empty())) causes a panic during Arrow struct construction.
In datafusion/common/src/scalar/mod.rs:
• compact_view_buffers and ScalarValue::new_default unconditionally call StructArray::new(...). When a struct has zero fields, no child arrays exist to infer the row length from, leading to a panic in arrow-rs
To Reproduce
use std::sync::Arc;
use arrow::array::StructArray;
use datafusion_common::ScalarValue;
let mut scalar = ScalarValue::Struct(Arc::new(StructArray::new_empty_fields(3, None)));
scalar.compact(); // Panics in StructArray::new
Expected behavior
Zero-field structs should be constructed using StructArray::new_empty_fields(length, nulls) instead of StructArray::new(...).
Additional context
Affects downstream consumers (e.g., Comet) when accumulators call ScalarValue::compact() on empty struct columns or nested containers (List<Struct<>>).
Describe the bug
Calling ScalarValue::compact() or ScalarValue::new_default() on a zero-field struct schema (DataType::Struct(Fields::empty())) causes a panic during Arrow struct construction.
In datafusion/common/src/scalar/mod.rs:
• compact_view_buffers and ScalarValue::new_default unconditionally call StructArray::new(...). When a struct has zero fields, no child arrays exist to infer the row length from, leading to a panic in arrow-rs
To Reproduce
Expected behavior
Zero-field structs should be constructed using StructArray::new_empty_fields(length, nulls) instead of StructArray::new(...).
Additional context
Affects downstream consumers (e.g., Comet) when accumulators call ScalarValue::compact() on empty struct columns or nested containers (List<Struct<>>).