Skip to content

[branch-55] fix(common): support empty struct in ScalarValue::compact and new_default (#24582) - #24876

Merged
timsaucer merged 1 commit into
apache:branch-55from
timsaucer:fix/backport-24582
Sep 2, 2026
Merged

[branch-55] fix(common): support empty struct in ScalarValue::compact and new_default (#24582)#24876
timsaucer merged 1 commit into
apache:branch-55from
timsaucer:fix/backport-24582

Conversation

@timsaucer

Copy link
Copy Markdown
Member

This is a back port of #24582 into branch-55 for inclusion in 55.1.0. Please see the original PR for details.

…ault (apache#24582)

## Which issue does this PR close?

Closes apache#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.
@github-actions github-actions Bot added the common Related to common crate label Sep 2, 2026
@timsaucer
timsaucer requested a review from Jefffrey September 2, 2026 11:47
@timsaucer

Copy link
Copy Markdown
Member Author

@unikdahal as the original author could you please review the back port?

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.59259% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.19%. Comparing base (1540853) to head (cae0337).

Files with missing lines Patch % Lines
datafusion/common/src/scalar/mod.rs 92.59% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           branch-55   #24876   +/-   ##
==========================================
  Coverage      81.19%   81.19%           
==========================================
  Files           1110     1110           
  Lines         387713   387773   +60     
  Branches      387713   387773   +60     
==========================================
+ Hits          314785   314841   +56     
- Misses         54412    54413    +1     
- Partials       18516    18519    +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@unikdahal unikdahal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @timsaucer LGTM

@timsaucer

Copy link
Copy Markdown
Member Author

Thank you @Jefffrey and @unikdahal

@timsaucer
timsaucer merged commit 573f816 into apache:branch-55 Sep 2, 2026
34 checks passed
@timsaucer
timsaucer deleted the fix/backport-24582 branch September 2, 2026 13:40
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.

4 participants