Support pushing down empty projections into joins#20191
Merged
Conversation
261c92b to
dc95119
Compare
kosiew
reviewed
Feb 11, 2026
kosiew
approved these changes
Feb 12, 2026
a59eed0 to
de897ca
Compare
de897ca to
95affa3
Compare
Contributor
|
Thanks @jackkleeman and @kosiew 🚀 |
jackkleeman
added a commit
to restatedev/datafusion
that referenced
this pull request
Feb 17, 2026
- Closes apache#20190. We should push down empty projections into HashJoinExec 1. try_embed_projection should embed empty projections 2. build_batch_empty_build_side should support empty schemas Yes No
jackkleeman
added a commit
to restatedev/datafusion
that referenced
this pull request
Feb 17, 2026
- Closes apache#20190. We should push down empty projections into HashJoinExec 1. try_embed_projection should embed empty projections 2. build_batch_empty_build_side should support empty schemas Yes No
de-bgunter
pushed a commit
to de-bgunter/datafusion
that referenced
this pull request
Mar 24, 2026
## Which issue does this PR close? - Closes apache#20190. ## Rationale for this change We should push down empty projections into HashJoinExec ## What changes are included in this PR? 1. try_embed_projection should embed empty projections 2. build_batch_empty_build_side should support empty schemas ## Are these changes tested? Yes ## Are there any user-facing changes? No
pull Bot
pushed a commit
to buraksenn/datafusion
that referenced
this pull request
Jun 25, 2026
…LoopJoinExec` (apache#23082) ## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Closes apache#23083 ## Rationale for this change `HashJoinExec` and `NestedLoopJoinExec` carry `projection: Option<Vec<usize>>` but the proto field is `repeated uint32`. Proto3 can't tell `None` from `Some(vec![])`, and the decoder treats both as `None`. `Some(vec![])` is reachable in real plans — `try_embed_projection` produces it for `SELECT count(1) … JOIN …` (apache#20191) — and after a round-trip the join silently switches from "emit zero columns" to "emit all columns". `FilterExec` has a workaround for the same limitation; these two execs were missed. ## What changes are included in this PR? Encode `Some(vec![])` as the single-element sentinel `[u32::MAX]` (never a valid column index); recognise it on decode. Everything else goes through unchanged. ```rust // encode projection: match exec.projection.as_ref() { None => Vec::new(), Some(v) if v.is_empty() => vec![u32::MAX], Some(v) => v.iter().map(|x| *x as u32).collect(), }, // decode let projection = match hashjoin.projection.as_slice() { [] => None, [u32::MAX] => Some(Vec::new()), indices => Some(indices.iter().map(|i| *i as usize).collect()), }; ``` Applied symmetrically to `HashJoinExec` and `NestedLoopJoinExec`. ## Are these changes tested? yes, add roundtrip test case ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
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.
Which issue does this PR close?
ProjectionExecis not embedded intoHashJoinExecby projection pushdown #20190.Rationale for this change
We should push down empty projections into HashJoinExec
What changes are included in this PR?
Are these changes tested?
Yes
Are there any user-facing changes?
No