Skip to content

fix(common): support empty struct in ScalarValue::compact and new_default - #24582

Open
unikdahal wants to merge 1 commit into
apache:mainfrom
unikdahal:fix-scalar-compact-empty-struct
Open

fix(common): support empty struct in ScalarValue::compact and new_default#24582
unikdahal wants to merge 1 commit into
apache:mainfrom
unikdahal:fix-scalar-compact-empty-struct

Conversation

@unikdahal

Copy link
Copy Markdown

Which issue does this PR close?

Closes #24581.

Rationale for this change

StructArray::new panics for structs with zero fields because it cannot infer array length from an empty column list. This hit two code paths in ScalarValue: new_default when building a default value for a zero-field struct type, and compact_view_buffers (used by ScalarValue::compact) when compacting a struct array that has zero fields but a nonzero row count.

What changes are included in this PR?

  • ScalarValue::new_default and compact_view_buffers now special-case zero-field structs, using StructArray::new_empty_fields (which takes an explicit length/nulls instead of inferring it from columns) rather than StructArray::new.
  • Added test_compact_empty_struct covering 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant