Skip to content

Preserve rows when sorting zero-column batches - #54

Merged
osipovartem merged 1 commit into
expr-planner-aggregate-schemafrom
fix-zero-column-sort
Sep 2, 2026
Merged

Preserve rows when sorting zero-column batches#54
osipovartem merged 1 commit into
expr-planner-aggregate-schemafrom
fix-zero-column-sort

Conversation

@osipovartem

Copy link
Copy Markdown
Collaborator

Summary

  • preserve row counts when IncrementalSortIterator takes rows from a zero-column RecordBatch
  • retain the existing Arrow take_record_batch path for batches with columns
  • add a focused regression test for selecting and reordering rows from an empty schema

Why

Arrow's take_record_batch reconstructs a batch from its columns without passing an explicit row count. For a valid zero-column batch this fails with must either specify a row count or at least one column. DataFusion can produce such batches after projection pruning, including queries that sort a row generator by an expression used only by a window function.

This PR is stacked on #53 because preserving the sort is what exposes this independent zero-column execution path in the original Rustice compatibility case.

Validation

  • cargo +1.97.0 test -p datafusion-physical-plan take_zero_column_batch_preserves_selected_row_count --lib
  • cargo +1.97.0 clippy -p datafusion-physical-plan --lib --tests
  • cargo +1.97.0 fmt --all -- --check

@osipovartem
osipovartem deleted the branch expr-planner-aggregate-schema September 2, 2026 18:05
@osipovartem osipovartem closed this Sep 2, 2026
@osipovartem osipovartem reopened this Sep 2, 2026
@osipovartem
osipovartem changed the base branch from fix-volatile-expression-constant to expr-planner-aggregate-schema September 2, 2026 18:08
@osipovartem
osipovartem merged commit d434a58 into expr-planner-aggregate-schema Sep 2, 2026
67 of 78 checks passed
@osipovartem
osipovartem deleted the fix-zero-column-sort branch September 2, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant