You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "terrymanu (via GitHub)" <gi...@apache.org> on 2026/08/23 01:50:36 UTC
[PR] Support MERGE INTO, CREATE TRIGGER and CREATE TABLE AS SELECT parsing for PostgreSQL [shardingsphere]
terrymanu opened a new pull request, #39569:
URL: https://github.com/apache/shardingsphere/pull/39569
- Add PostgreSQL MERGE grammar with WHEN MATCHED THEN DO UPDATE / DELETE / DO NOTHING, WHEN NOT MATCHED THEN INSERT / DO NOTHING, AND conditions, USING table or subquery sources and RETURNING clause
- Add MERGE and MATCHED keywords to PostgreSQL lexer as unreserved words
- Extend shared MergeStatement with returning segment and MergeWhenAndThenSegment with delete statement; fill delete action in SQLServer and Hive merge visitors
- Add visitCreateTrigger for PostgreSQL and map trigger name and target table
- Map AS SELECT clause in PostgreSQL visitCreateTable into CreateTableStatement
- Fix PostgreSQL createTable grammar so column definitions are optional for CTAS, and make constraint trigger function arguments optional
- Add parser IT cases for all new statements and expected structures
Fixes #26801.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support MERGE INTO, CREATE TRIGGER and CREATE TABLE AS SELECT parsing for PostgreSQL [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on PR #39569:
URL: https://github.com/apache/shardingsphere/pull/39569#issuecomment-5383700715
### Result
**Review Result: Mergeable**
The single blocking issue from the previous review round is fixed on the latest head `864d92f7668`: the MERGE matched-action grammar now matches the official PostgreSQL syntax (`UPDATE SET`, no in-action `WHERE`), the visitor mapping and IT cases were updated in the same fix boundary, and the full parser IT suite passes on the exact head content. No new issue is introduced by the latest commit.
### Evidence
- Grammar at head `864d92f7668`, `parser/sql/engine/dialect/postgresql/src/main/antlr4/imports/postgresql/DMLStatement.g4:118-121`: `mergeMatchedThenClause : UPDATE SET setClauseList | DELETE | DO NOTHING` — matches `merge_update`/`merge_delete`/`DO NOTHING` in the official PostgreSQL 16 and current (18) [sql-merge.html](https://www.postgresql.org/docs/current/sql-merge.html), which defines `UPDATE SET ...` with no table name and no WHERE clause. The official documentation example shape (`WHEN MATCHED AND ... THEN UPDATE SET col = expr`) is now parseable.
- Test cases at head: `test/it/parser/src/main/resources/sql/supported/dml/merge.xml` contains 7 PostgreSQL cases with zero `DO UPDATE` occurrences; `merge_pg_when_matched_then_update`, the multi-WHEN case without the illegal `WHERE`, and the RETURNING case all use the official form; expected structures in `case/dml/merge.xml` align case-for-case (21/21).
- Visitor at head: `PostgreSQLStatementVisitor#fillMatchedThenClause` maps `DELETE` and `UPDATE SET` only; no where handling remains.
- Scope integrity: GitHub changed-file list (21 files) is identical to the local `git diff fc009d8...864d92f` triple-dot list; the second commit's delta is confined to the 4 fix-boundary files (grammar, visitor, two merge XMLs, +28/−53).
- Local verification on the exact head content (sanitized, exit 0): full `test/it/parser` suite across all dialects — 9215 tests, 0 failures, 0 errors, BUILD SUCCESS; `spotless:apply` and `checkstyle:check` pass.
- PR has no comments or reviews; no community feedback to address.
### Coverage
- Reviewed head `864d92f7668` (2 commits; latest delta re-reviewed in full), base/merge-base `fc009d8ca7`, 21/21 files mapped to the five behavior clusters from the previous round (PG MERGE grammar/keywords/visitor; shared merge-model extension with SQLServer/Hive convergence; PG CREATE TRIGGER; PG CTAS; IT assertion trio). The fix modifies only cluster ①; clusters ②–⑤ are byte-identical to the previously reviewed head state.
- All three discovery lenses completed with a convergence pass over the latest commit; no new independent candidates.
- Dialect family checked: PostgreSQL (trunk, no branches); SQLServer and Hive convergence verified; openGauss grammar independent and unaffected.
- Official documentation used: PostgreSQL 16 and current [sql-merge.html](https://www.postgresql.org/docs/16/sql-merge.html); CREATE TRIGGER and CREATE TABLE AS implementations align with official syntax.
- Non-blocking observations carried forward, none affecting mergeability: PG 18's `WHEN NOT MATCHED BY SOURCE` not covered; CREATE TRIGGER lacks PG 14+ `OR REPLACE` and a trigger name on the constraint branch; `USING tableReference` accepts a bare JOIN as source where official syntax allows only a single table or parenthesized query; MERGE `RETURNING` is accepted ahead of PG 18 which introduced it.
- This is a Code Correctness Review: the result is code-scope only and CI was not queried, waited on, or reported.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support MERGE INTO, CREATE TRIGGER and CREATE TABLE AS SELECT parsing for PostgreSQL [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu merged PR #39569:
URL: https://github.com/apache/shardingsphere/pull/39569
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org