kosiew opened a new pull request, #20772:
URL: https://github.com/apache/datafusion/pull/20772
## 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.
-->
- Part of #19950
## Rationale for this change
Today the planner rejects `UPDATE ... FROM`, which blocks follow-on work in
execution and provider layers. This change makes the statement representable in
the logical plan without introducing provider APIs or execution changes. It
also preserves the original target-row image in hidden projection columns so
downstream layers can distinguish between:
- the new values that should replace the target row
- the original target-row values needed to map joined update results back
onto the table
## What changes are included in this PR?
- remove the planner-side `not_impl` rejection for single-source `UPDATE ...
FROM`
- plan `UPDATE ... FROM` by building the update input from the target table
plus the single `FROM` source
- project updated target-column values in target schema order, casting
assignment expressions to the target field type when needed
- add hidden old-row projection columns using the `__df_update_old_` prefix
so downstream layers can recover the original target row after the join
- factor target-column expression construction into a helper so aliased and
non-aliased target references are handled consistently
- add SQL integration coverage for:
- standard `UPDATE ... FROM`
- `FROM` appearing before `SET`
- aliased target/source tables while still projecting the original target
row
- remove sqllogictest cases that asserted `UPDATE ... FROM` was unsupported,
since this PR enables planning only and those execution-oriented cases are no
longer the right coverage for this slice
## Are these changes tested?
Yes.
- added planner-focused integration tests in
`datafusion/sql/tests/sql_integration.rs` covering the supported `UPDATE ...
FROM` forms and old-row projection behavior
- removed sqllogictest assertions that expected planner rejection of `UPDATE
... FROM`
- locally verified with:
```bash
cargo test -p datafusion-sql plan_update_from --test sql_integration
```
## Are there any user-facing changes?
Yes. SQL planning now accepts single-source `UPDATE ... FROM` statements,
including aliased forms and `FROM` before `SET`, and produces a logical plan
instead of returning `UPDATE ... FROM is not supported`.
This PR is still planner-only. It does not add new execution/provider
behavior yet.
## LLM-generated code disclosure
This PR includes LLM-generated code and comments. All LLM-generated content
has been manually reviewed and tested.
--
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]