Skip to content

panic: 'StructArray::new' on zero-field (empty) structs in ScalarValue::compact and ScalarValue::new_default #24581

Closed

Description

@unikdahal

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<>>).

Activity

  1. added theissue type on Aug 22, 2026
  2. unikdahal commented on Aug 22, 2026

    @unikdahal
    ContributorAuthor

    take

  3. added a commit that references this issue on Aug 30, 2026
    74f4dd6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions