Repository navigation
feat: show MERGE INTO details in EXPLAIN - #26038
wirybeaver wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #26038 +/- ##
=======================================
Coverage 82.66% 82.66%
=======================================
Files 1147 1147
Lines 446357 446426 +69
Branches 446357 446426 +69
=======================================
+ Hits 368971 369041 +70
+ Misses 54997 54982 -15
- Partials 22389 22403 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kosiew
left a comment
There was a problem hiding this comment.
Thanks for improving the MERGE INTO logical-plan display. The change addresses the issue by exposing the ON condition and ordered WHEN clauses in both text and PostgreSQL JSON output. The approach is appropriate, and the additional regression coverage exercises the main formatting paths.
The formatting responsibility stays with the types that own the merge details, while the logical-plan display layers decide how to present them. This preserves the existing planning and execution boundaries, avoids duplicating action formatting, and keeps non-MERGE text output unchanged. The additional complexity is justified by the diagnostic value.
I'm approving because the issue requirements are satisfied and I found no blocking correctness concerns. I left two non-blocking suggestions concerning identifier quoting and stronger JSON contract tests, including coverage of the broader DML node-type change.
| if i > 0 { | ||
| write!(f, ", ")?; | ||
| } | ||
| write!(f, "{column} = {value}")?; |
There was a problem hiding this comment.
Could we use datafusion_common::utils::quote_identifier for UPDATE assignment targets and INSERT column names when quoting is needed? Currently First Name loses its identifier boundaries, and a name like a, b would look like two columns. Please adjust the existing test and include a comma or embedded-quote identifier. This is a readability improvement, not an execution issue.
| "Dml: op=[MergeInto] table=[person_quoted_cols] on=[t.id = s.j2_id] clauses=[WHEN MATCHED THEN UPDATE SET First Name = s.j2_string, WHEN NOT MATCHED THEN INSERT (id, Age) VALUES (s.j2_id, Int64(42))]" | ||
| ); | ||
|
|
||
| let json = plan.display_pg_json().to_string(); |
There was a problem hiding this comment.
Could we parse the JSON and assert the root Clauses array contains both expected strings in SQL order, along with On, Operation, and Table Name? The substring checks miss the array shape, second clause, and ordering. It would also help to test non-MERGE DML for the changed Node Type and absence of MERGE-only keys, and confirm that the broader node-type change is intentional.
Include the ON condition and WHEN clauses in text and PostgreSQL JSON logical-plan output for MERGE INTO.
4d15378 to
9550dcf
Compare
Which issue does this PR close?
Follow-up to the MERGE INTO review in #22988 and split from #24195. No separate issue.
Rationale for this change
Logical-plan output for
MERGE INTOcurrently shows onlyop=[MergeInto]. It omits theONcondition andWHENactions, which makesEXPLAINless useful for understanding or debugging a merge plan.What changes are included in this PR?
ONcondition and orderedWHEN ... THEN ...clauses in indented logical-plan output.Dmlrather thanProjection.This PR is independent of #24195 and targets
maindirectly. The two PRs only modify separate expectations in the sharedmerge_into.slttest file.What is the testing strategy for this PR?
cargo fmt --allcargo check -p datafusion-expr -p datafusion-sqlcargo test -p datafusion-expr write_op_merge_into_name_and_display -- --nocapturecargo test -p datafusion-sql plan_merge_into_preserves_target_qualifier_and_quoted_columns -- --nocapturecargo test --profile ci --test sqllogictests -- merge_into.slt --nocapturecargo clippy --all-targets --all-features -- -D warningsAre there any user-facing changes?
Yes.
EXPLAINtext and PostgreSQL JSON output forMERGE INTOnow include the merge condition and clauses. There are no public API signature changes.