Skip to content

fix(plan): dedup update from source matches (cherry-pick #24932)#24934

Open
ck89119 wants to merge 2 commits into
matrixorigin:3.0-devfrom
ck89119:issue-23137-3.0-dev
Open

fix(plan): dedup update from source matches (cherry-pick #24932)#24934
ck89119 wants to merge 2 commits into
matrixorigin:3.0-devfrom
ck89119:issue-23137-3.0-dev

Conversation

@ck89119

@ck89119 ck89119 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #23137

What this PR does / why we need it:

Cherry-pick of #24932 to 3.0-dev.

This PR fixes the PostgreSQL-style UPDATE ... SET ... FROM ... WHERE ... path when duplicate source rows match the same target row on tables without FK constraints.

The new UPDATE path previously fed duplicate joined rows directly into the update pipeline, which could materialize duplicate primary-key rows for one target row. This change adds a planner-side dedup step for UPDATE ... FROM: group by the target row's original columns and use any_value() for updated columns, matching the existing fallback path behavior.

3.0-dev adaptation:

  • Removed the SpillMem field initialization from the new AGG node because 3.0-dev does not have plan.Node.SpillMem or QueryBuilder.aggSpillMem.

Tested with:

  • git diff --check
  • go test ./pkg/sql/plan -run TestUpdatePgStyleFromDedupsDuplicateSourceMatchesOnNewPath -count=1

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

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

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants