Skip to content

fix(parser): support PostgreSQL-style UPDATE ... SET ... FROM ... WHERE#24536

Merged
mergify[bot] merged 6 commits into
matrixorigin:mainfrom
ck89119:issue-23137
May 25, 2026
Merged

fix(parser): support PostgreSQL-style UPDATE ... SET ... FROM ... WHERE#24536
mergify[bot] merged 6 commits into
matrixorigin:mainfrom
ck89119:issue-23137

Conversation

@ck89119
Copy link
Copy Markdown
Contributor

@ck89119 ck89119 commented May 22, 2026

What type of PR is this?

  • BUG

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.:

UPDATE vec_join_case t
SET remark = CONCAT('hot-', c.province)
FROM company c
WHERE c.id = t.company_id
  AND l2_distance(embedding,"[0.2,0.2,0.3,0.3]") < 0.35;

Change

Add a new production to update_no_with_stmt in pkg/sql/parsers/dialect/mysql/mysql_sql.y:

UPDATE priority_opt ignore_opt table_reference SET update_list FROM table_references where_expression_opt

The grammar action cross-joins the target table with the FROM-clause tables and stores the result in Update.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.

make validates that the grammar still has zero shift/reduce conflicts.

Tests

  • Parser unit tests in mysql_sql_test.go cover the basic case, the issue's vector-distance case, multiple tables in the FROM clause, the WITH ... UPDATE ... FROM shape, and UPDATE ... JOIN ... SET ... FROM.
  • Planner unit tests in build_test.go exercise the new syntax against the mock optimizer (success + table/column-not-found error paths).
  • A new BVT case test/distributed/cases/dml/update/update_pg_style_from.sql exercises the end-to-end behavior, including the original failing SQL from the issue.

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-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 →

Copy link
Copy Markdown
Contributor

@aunjgr aunjgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mergify mergify Bot added the queued label May 25, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 25, 2026

Merge Queue Status

  • Entered queue2026-05-25 03:37 UTC · Rule: main
  • Checks passed · in-place
  • Merged2026-05-25 04:38 UTC · at d573e7266ed6066bd351ee20e15c72444b30c7e6 · squash

This pull request spent 1 hour 59 seconds in the queue, including 1 hour 37 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage

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/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants