Add parser support for SQL MERGE#7126
Conversation
core/trino-parser/src/main/java/io/trino/sql/tree/MergeDelete.java
Outdated
Show resolved
Hide resolved
core/trino-parser/src/main/java/io/trino/sql/tree/MergeDelete.java
Outdated
Show resolved
Hide resolved
core/trino-parser/src/main/java/io/trino/sql/tree/MergeInsert.java
Outdated
Show resolved
Hide resolved
core/trino-parser/src/main/java/io/trino/sql/tree/MergeUpdate.java
Outdated
Show resolved
Hide resolved
core/trino-parser/src/test/java/io/trino/sql/parser/TestSqlParser.java
Outdated
Show resolved
Hide resolved
5e39f14 to
7d36957
Compare
|
Thanks for the very prompt review, @electrum! I've force-pushed the suggested changes. |
kasiafi
left a comment
There was a problem hiding this comment.
A couple of comments and questions. This is a great change!
core/trino-parser/src/main/java/io/trino/sql/tree/MergeInsert.java
Outdated
Show resolved
Hide resolved
core/trino-parser/src/test/java/io/trino/sql/parser/TestSqlParser.java
Outdated
Show resolved
Hide resolved
core/trino-parser/src/test/java/io/trino/sql/parser/TestSqlParser.java
Outdated
Show resolved
Hide resolved
core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4
Outdated
Show resolved
Hide resolved
core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4
Outdated
Show resolved
Hide resolved
core/trino-parser/src/main/java/io/trino/sql/parser/AstBuilder.java
Outdated
Show resolved
Hide resolved
core/trino-parser/src/main/java/io/trino/sql/tree/MergeCase.java
Outdated
Show resolved
Hide resolved
core/trino-parser/src/main/java/io/trino/sql/tree/AstVisitor.java
Outdated
Show resolved
Hide resolved
core/trino-parser/src/main/java/io/trino/sql/tree/DefaultTraversalVisitor.java
Outdated
Show resolved
Hide resolved
|
As part of this PR, please catch MERGE statements in the |
7d36957 to
422afe6
Compare
|
Thanks for the excellent, detailed review, @kasiafi! I force-pushed changes that address your review comments. |
422afe6 to
904b6a7
Compare
|
Thanks for updating! I can see there's a bunch of tests failing as a result of @mosabua could you please review the docs part? |
904b6a7 to
3c06db2
Compare
If they appear in non-conflicting contexts, we can make it a non-reserved keyword. Otherwise, we'll have to figure out how to deprecate and rename the conflicting function. |
3c06db2 to
9fb94d0
Compare
This commit adds the syntax rules and tree classes needed to parse and represent SQL MERGE syntax, accompanied by parser tests. Trino engine and Hive connector changes that implement SQL MERGE will be added in a follow-on PR.
9fb94d0 to
c63ac00
Compare
I was mistaken - - the SQL 2016 standard that introduced the |
Done. |
c63ac00 to
af99147
Compare
mosabua
left a comment
There was a problem hiding this comment.
See my comment about Limitations for connectors.
| Limitations | ||
| ----------- | ||
|
|
||
| Some connectors have limited or no support for ``MERGE``. |
There was a problem hiding this comment.
This is similar to what is in UPDATE .. I am concerned that this is not really true at this stage. Its more like "Nearly no connectors have support for MERGE.". And the connector docs also dont have this in a limitations section consistently.
@electrum I think we should ensure all connectors have a Limitations section and then add MERGE and UPDATE to all the ones affected.
There was a problem hiding this comment.
I feel like we need a better way to address this than making it an NxM problem.
There was a problem hiding this comment.
Agreed .. the best would be consistent implementation of such things across all connectors so we just have to call out a few exceptions. Currently I think it would be great to just go in depth on the docs and then use that assembled knowledge to drive consistency in the implementation to clean things up. Currently its all kind of hidden in the code only and thats just really hard for users (and probably even developers when assessing impact of changes..)
There was a problem hiding this comment.
But all this should be a separate larger effort outside of the scope of this PR for sure..
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
ANTLR syntax rules, tree classes to parse and represent SQL MERGE syntax, and parser tests. Changes were done after reviewing the following Trino PR: trinodb/trino#7126 So, this commit is deeply inspired by Trino's implementation. Co-authored-by: David Stryker <david.stryker@starburstdata.com>
Since complete support for SQL MERGE in Trino and the Hive connector is 5,700 lines of code, @electrum suggested that the parser changes be submitted as this separate PR.
This single commit adds the syntax rules and tree classes needed to parse and represent SQL MERGE syntax, accompanied by parser tests.