-
Notifications
You must be signed in to change notification settings - Fork 5.5k
feat: Add SQL Support for MERGE INTO in Presto (engine) #26278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add SQL Support for MERGE INTO in Presto (engine) #26278
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @acarpente-denodo, your pull request is larger than the review limit of 150000 diff characters
b8f9b3e
to
b27ac47
Compare
71aebc7
to
6f60239
Compare
Please include documentation for SQL MERGE INTO
as a new file in
https://github.com/prestodb/presto/tree/master/presto-docs/src/main/sphinx/sql
and add the new file to the index page
https://github.com/prestodb/presto/blob/master/presto-docs/src/main/sphinx/sql.rst
6f60239
to
7a54a60
Compare
Hi @steveburnett. I appreciate your feedback. I added a new commit that includes the documentation for the MERGE INTO command.
7a54a60
to
8a860c1
Compare
Working in progress Cherry-pick of trinodb/trino@cee96c3 Co-authored-by: David Stryker <david.stryker@starburstdata.com>
Automated tests. Cherry-pick of trinodb/trino@cee96c3 Co-authored-by: David Stryker <david.stryker@starburstdata.com>
Added MERGE INTO statement documentation.
8a860c1
to
61ea3bd
Compare
Uh oh!
There was an error while loading. Please reload this page.
Description
Engine support for SQL MERGE INTO. The MERGE INTO command inserts or updates rows in a table based on specified conditions.
Syntax:
Example: MERGE INTO usage to update the sales information for existing products and insert the sales information for the new products in the market.
The Presto engine commit introduces an enum called RowChangeParadigm, which describes how a connector modifies rows. The iceberg connector will utilize the
DELETE_ROW_AND_INSERT_ROW
paradigm, as it represents an updated row as a combination of a deleted row followed by an inserted row. TheCHANGE_ONLY_UPDATED_COLUMNS
paradigm is meant for connectors that support updating individual columns of rows.Note: Changes were made after reviewing the following Trino PR: trinodb/trino#7126
So, this commit is deeply inspired by Trino's implementation.
Motivation and Context
The
MERGE INTO
statement is commonly used to integrate data from two tables with different contents but similar structures.For example, the source table could be part of a production transactional system, while the target table might be located in a data warehouse for analytics.
Regularly, MERGE operations are performed to update the analytics warehouse with the latest production data.
You can also use MERGE with tables that have different structures, as long as you can define a condition to match the rows between them.
Test Plan
Automated tests developed in TestSqlParser, TestSqlParserErrorHandling, TestStatementBuilder, AbstractAnalyzerTest, TestAnalyzer, and TestClassLoaderSafeWrappers classes.
Contributor checklist
Release Notes