Skip to content

Add parser support for SQL MERGE#7126

Merged
electrum merged 3 commits intotrinodb:masterfrom
djsagain:david.stryker/sql-merge-parser
Mar 12, 2021
Merged

Add parser support for SQL MERGE#7126
electrum merged 3 commits intotrinodb:masterfrom
djsagain:david.stryker/sql-merge-parser

Conversation

@djsagain
Copy link
Copy Markdown
Member

@djsagain djsagain commented Mar 2, 2021

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.

@cla-bot cla-bot bot added the cla-signed label Mar 2, 2021
@djsagain djsagain requested review from electrum, kasiafi and martint March 2, 2021 19:39
Copy link
Copy Markdown
Member

@electrum electrum left a comment

Choose a reason for hiding this comment

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

Looks good overall

@djsagain djsagain force-pushed the david.stryker/sql-merge-parser branch from 5e39f14 to 7d36957 Compare March 3, 2021 04:38
@djsagain
Copy link
Copy Markdown
Member Author

djsagain commented Mar 3, 2021

Thanks for the very prompt review, @electrum! I've force-pushed the suggested changes.

Copy link
Copy Markdown
Member

@kasiafi kasiafi left a comment

Choose a reason for hiding this comment

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

A couple of comments and questions. This is a great change!

@kasiafi
Copy link
Copy Markdown
Member

kasiafi commented Mar 3, 2021

As part of this PR, please catch MERGE statements in the StatementAnalyzer and fail them with NOT_SUPPORTED.

@djsagain djsagain force-pushed the david.stryker/sql-merge-parser branch from 7d36957 to 422afe6 Compare March 3, 2021 18:48
@djsagain
Copy link
Copy Markdown
Member Author

djsagain commented Mar 3, 2021

Thanks for the excellent, detailed review, @kasiafi! I force-pushed changes that address your review comments.

@djsagain djsagain force-pushed the david.stryker/sql-merge-parser branch from 422afe6 to 904b6a7 Compare March 4, 2021 03:57
@kasiafi
Copy link
Copy Markdown
Member

kasiafi commented Mar 4, 2021

Thanks for updating!
Please address this comment: #7126 (comment)

I can see there's a bunch of tests failing as a result of MERGE being a reserved word. Actually, it collides with a function name merge. I think, it should be non-reserved then. But it is a reserved keyword. @martint what's your opinion?

@mosabua could you please review the docs part?

@djsagain djsagain force-pushed the david.stryker/sql-merge-parser branch from 904b6a7 to 3c06db2 Compare March 4, 2021 15:27
@martint
Copy link
Copy Markdown
Member

martint commented Mar 4, 2021

I can see there's a bunch of tests failing as a result of MERGE being a reserved word. Actually, it collides with a function name merge. I think, it should be non-reserved then. But it is a reserved keyword. @martint what's your opinion?

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.

@djsagain djsagain force-pushed the david.stryker/sql-merge-parser branch from 3c06db2 to 9fb94d0 Compare March 4, 2021 18:55
David Stryker added 2 commits March 4, 2021 11:05
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.
@djsagain djsagain force-pushed the david.stryker/sql-merge-parser branch from 9fb94d0 to c63ac00 Compare March 4, 2021 19:18
@djsagain
Copy link
Copy Markdown
Member Author

djsagain commented Mar 4, 2021

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.

I was mistaken - - the SQL 2016 standard that introduced the MERGE statement does not define the token "MERGE" as a reserved word. I removed the reserved word status for MERGE in this PR, and the merge(HyperLogLog) parses again. Sorry for the misconception.

@djsagain
Copy link
Copy Markdown
Member Author

djsagain commented Mar 4, 2021

As part of this PR, please catch MERGE statements in the StatementAnalyzer and fail them with NOT_SUPPORTED.

Done.

@djsagain djsagain force-pushed the david.stryker/sql-merge-parser branch from c63ac00 to af99147 Compare March 9, 2021 18:38
Copy link
Copy Markdown
Member

@mosabua mosabua left a comment

Choose a reason for hiding this comment

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

See my comment about Limitations for connectors.

Limitations
-----------

Some connectors have limited or no support for ``MERGE``.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I feel like we need a better way to address this than making it an NxM problem.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But all this should be a separate larger effort outside of the scope of this PR for sure..

@electrum electrum merged commit 832c0de into trinodb:master Mar 12, 2021
@djsagain djsagain deleted the david.stryker/sql-merge-parser branch March 13, 2021 14:42
@findepi findepi mentioned this pull request Apr 22, 2021
6 tasks
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Jul 8, 2024
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Jul 30, 2024
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Nov 4, 2024
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Dec 16, 2024
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Jan 9, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Jan 31, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request May 28, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Jul 2, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Jul 3, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Jul 4, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Jul 11, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Jul 14, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Jul 21, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 1, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 4, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 4, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 6, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 7, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 7, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 8, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 12, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 12, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 13, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 18, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 19, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Aug 21, 2025
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>
acarpente-denodo added a commit to acarpente-denodo/presto that referenced this pull request Sep 8, 2025
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants