Skip to content

fix(planner): make DML target-branch discovery UPDATE/DELETE-safe (restore DELETE ... LIMIT)#20771

Closed
kosiew wants to merge 5 commits intoapache:mainfrom
kosiew:update-bug-01-19950
Closed

fix(planner): make DML target-branch discovery UPDATE/DELETE-safe (restore DELETE ... LIMIT)#20771
kosiew wants to merge 5 commits intoapache:mainfrom
kosiew:update-bug-01-19950

Conversation

@kosiew
Copy link
Contributor

@kosiew kosiew commented Mar 7, 2026

Which issue does this PR close?

Rationale for this change

UPDATE ... FROM planning was rejected entirely, which blocked the baseline provider and planner work needed to support this statement shape at all. This PR implements the first scoped slice for #19950: enable planning and execution plumbing for baseline UPDATE ... FROM support without mixing in later correctness fixes and cleanup refactors in #20745

The goal of this PR is to land the foundational path first:

  • allow UPDATE ... FROM through SQL planning
  • preserve source-table qualifiers in joined assignments
  • add a provider hook for multi-table updates
  • route physical planning through that hook when the update input contains a join
  • add the minimum planner and SQLLogicTest coverage needed to prove the path works

Follow-up fixes for target-row image correctness and related edge cases are intentionally left to later PRs.

What changes are included in this PR?

Are these changes tested?

Yes.

This PR adds targeted coverage for:

  • planner behavior for UPDATE ... FROM
  • assignment extraction for joined updates and aliases
  • provider routing through update_from(...)
  • SQLLogicTest coverage for baseline UPDATE ... FROM statements

Validated with:

  • cargo test -p datafusion --test core_integration custom_sources_cases::dml_planning -- --nocapture
  • cargo test -p datafusion-sqllogictest update -- --nocapture

Are there any user-facing changes?

Yes. DataFusion now accepts baseline UPDATE ... FROM statements, including aliased forms covered by the new tests, instead of rejecting them as unsupported.

There is also a public API addition for custom table providers: TableProvider::update_from(...).

LLM-generated code disclosure

This PR includes LLM-generated code and comments. All LLM-generated content has been manually reviewed and tested.

kosiew added 5 commits March 7, 2026 12:57
Enhance testing for UPDATE ... FROM alias and shape variants in
update.slt. Introduce targeted planner/unit tests for qualifier
and joined-assignment patterns in dml_planning.rs, currently
asserting for the existing guard error.
Remove hard guard for UPDATE ... FROM in SQL planner.
Enhance assignment extraction to preserve
qualifiers for multi-table updates and filter
identity assignments with target-table awareness.
Update API docs to clarify multi-table update
behavior and add integration and unit tests to
validate new functionality and expectations.
@github-actions github-actions bot added sql SQL Planner core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) catalog Related to the catalog crate labels Mar 7, 2026
@kosiew kosiew closed this Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

catalog Related to the catalog crate core Core DataFusion crate sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant