Skip to content

feat: show MERGE INTO details in EXPLAIN - #26038

Open
wirybeaver wants to merge 1 commit into
apache:mainfrom
wirybeaver:mergeExplain
Open

wirybeaver wants to merge 1 commit into
apache:mainfrom
wirybeaver:mergeExplain

Conversation

@wirybeaver

Copy link
Copy Markdown
Contributor

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 INTO currently shows only op=[MergeInto]. It omits the ON condition and WHEN actions, which makes EXPLAIN less useful for understanding or debugging a merge plan.

What changes are included in this PR?

  • Adds display implementations for MERGE operations, clause kinds, clauses, and actions.
  • Includes the ON condition and ordered WHEN ... THEN ... clauses in indented logical-plan output.
  • Adds the same information to PostgreSQL JSON output and identifies DML nodes as Dml rather than Projection.
  • Adds text and JSON assertions covering aliases, quoted columns, predicates, updates, deletes, and inserts.

This PR is independent of #24195 and targets main directly. The two PRs only modify separate expectations in the shared merge_into.slt test file.

What is the testing strategy for this PR?

  • cargo fmt --all
  • cargo check -p datafusion-expr -p datafusion-sql
  • cargo test -p datafusion-expr write_op_merge_into_name_and_display -- --nocapture
  • cargo test -p datafusion-sql plan_merge_into_preserves_target_qualifier_and_quoted_columns -- --nocapture
  • cargo test --profile ci --test sqllogictests -- merge_into.slt --nocapture
  • cargo clippy --all-targets --all-features -- -D warnings
  • Full extended workspace test command from the contributor guide

Are there any user-facing changes?

Yes. EXPLAIN text and PostgreSQL JSON output for MERGE INTO now include the merge condition and clauses. There are no public API signature changes.

Include the ON condition and WHEN clauses in text and PostgreSQL JSON logical-plan output for MERGE INTO.
@github-actions github-actions Bot added sql SQL Planner logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt) labels Oct 4, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.38889% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.66%. Comparing base (c3ef346) to head (4d15378).

Files with missing lines Patch % Lines
datafusion/expr/src/logical_plan/dml.rs 73.58% 2 Missing and 12 partials ⚠️
datafusion/expr/src/logical_plan/plan.rs 60.00% 0 Missing and 2 partials ⚠️
datafusion/expr/src/logical_plan/display.rs 92.85% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants