haohuaijin opened a new pull request, #23082:
URL: https://github.com/apache/datafusion/pull/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 #.
## 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 …` (#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 is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]