fix(parser): support PostgreSQL-style UPDATE ... SET ... FROM ... WHERE#24536
Conversation
Allow UPDATE statements to introduce additional join sources via a FROM clause between SET and WHERE, matching the standard / PostgreSQL syntax. The grammar cross-joins the target with the FROM-clause tables so the existing multi-table UPDATE binder/planner path handles it unchanged. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
aunjgr
left a comment
There was a problem hiding this comment.
Review: PostgreSQL-style UPDATE ... FROM
Approve.
The parser/AST/planner wiring for UPDATE ... SET ... FROM is coherent, including preserving FROM join-tree associativity, limiting DML targets to the UPDATE target table(s), and forcing dedup handling for multi-match source rows. Coverage is broad (syntax, planner tests, and BVT scenarios including generated columns, self-join, and join-tree shape).
No blocking correctness issue found in this revision.
Merge Queue Status
This pull request spent 1 hour 59 seconds in the queue, including 1 hour 37 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #23137
What this PR does / why we need it:
UPDATE ... SET ... FROM ...(the standard / PostgreSQL syntax for joining additional tables into an UPDATE) previously failed at parse time. Typical enrichment workflows that need to update a target table by joining a dimension table or filtering by a vector predicate were blocked, e.g.:Change
Add a new production to
update_no_with_stmtinpkg/sql/parsers/dialect/mysql/mysql_sql.y:The grammar action cross-joins the target table with the
FROM-clause tables and stores the result inUpdate.Tables, so the existing multi-table UPDATE binder/planner path (pkg/sql/plan/bind_update.go,dml_context.go) handles the new shape unchanged. No AST/Format change, no planner change.makevalidates that the grammar still has zero shift/reduce conflicts.Tests
mysql_sql_test.gocover the basic case, the issue's vector-distance case, multiple tables in the FROM clause, theWITH ... UPDATE ... FROMshape, andUPDATE ... JOIN ... SET ... FROM.build_test.goexercise the new syntax against the mock optimizer (success + table/column-not-found error paths).test/distributed/cases/dml/update/update_pg_style_from.sqlexercises the end-to-end behavior, including the original failing SQL from the issue.