Preserve rows when sorting zero-column batches - #54
Merged
Conversation
osipovartem
changed the base branch from
fix-volatile-expression-constant
to
expr-planner-aggregate-schema
September 2, 2026 18:08
osipovartem
merged commit Sep 2, 2026
d434a58
into
expr-planner-aggregate-schema
67 of 78 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IncrementalSortIteratortakes rows from a zero-columnRecordBatchtake_record_batchpath for batches with columnsWhy
Arrow's
take_record_batchreconstructs a batch from its columns without passing an explicit row count. For a valid zero-column batch this fails withmust 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 --libcargo +1.97.0 clippy -p datafusion-physical-plan --lib --testscargo +1.97.0 fmt --all -- --check