wirybeaver opened a new pull request, #24195:
URL: https://github.com/apache/datafusion/pull/24195

   ## Which issue does this PR close?
   
   Follow-up to the MERGE INTO review in #22988. No separate issue.
   
   ## Rationale for this change
   
   `MERGE INTO` could be planned, but the built-in in-memory table provider 
could not execute it, and `EXPLAIN` only showed `op=[MergeInto]` without the 
`ON` condition or `WHEN` actions. This made the new SQL surface hard to 
exercise end-to-end with the default provider.
   
   ## What changes are included in this PR?
   
   - Adds display helpers for MERGE INTO operations, clauses, and actions, and 
includes `ON` / `WHEN ... THEN ...` details in text and JSON logical plan 
output.
   - Implements basic `MemTable` `MERGE INTO` execution for matched 
update/delete, not-matched insert, and not-matched-by-source update/delete.
   - Handles first matching clause semantics, NULL predicates as false, 
duplicate source matches for a target row as an error before mutation, insert 
column subsets with defaults or typed NULLs, expression casts to target column 
types, affected-row counts, and sort-order reset.
   - Documents `MERGE INTO` syntax, provider caveats, and currently unsupported 
planner syntax.
   - Extends sqllogictests and Rust tests for planning, display, execution, 
NULL/no-op predicates, defaults, and duplicate-match errors.
   
   ## Are these changes tested?
   
   Yes:
   
   - `cargo fmt --all`
   - `cargo test -p datafusion-expr`
   - `cargo test -p datafusion-catalog`
   - `cargo test -p datafusion --test core_integration merge_into -- 
--nocapture`
   - `cargo test -p datafusion-sql 
plan_merge_into_canonicalizes_qualifiers_and_preserves_quoted_columns -- 
--nocapture`
   - `cargo test --profile=ci --test sqllogictests -- merge_into.slt 
--nocapture`
   - `./ci/scripts/doc_prettier_check.sh --write --allow-dirty`
   - `cargo clippy --all-targets --all-features -- -D warnings`
   
   Note: the plan mentioned `cargo test -p datafusion --test sql`, but this 
repository does not currently have a `sql` test target; the relevant MERGE SQL 
tests live under `core_integration`.
   
   ## Are there any user-facing changes?
   
   Yes. `MemTable` now supports basic `MERGE INTO`, and `EXPLAIN` output for 
`MERGE INTO` includes the merge condition and clauses. There are no public API 
signature changes.
   


-- 
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]

Reply via email to