-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Support SQL MERGE for Phoenix connector #16693
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
Conversation
djsagain
left a comment
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.
In general the implementation of the merge-specific ConnectorMetadata methods look good to me, and I really like all the consistency checking you do in this PR.
I'm not approving, because I'm not familiar with the Jdbc connectors. I think you need to get an expert on Jdbc connectors to also review the PR. When they say they like what they see, I'll approve as well.
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMergeSink.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMergeSink.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMetadata.java
Outdated
Show resolved
Hide resolved
Thanks for your time! I have learnt a lot from your code.
|
kokosing
left a comment
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.
Can we first implement this in base-jdbc connector and then use it for phoenix? Phoenix was based on that library and I would like to keep this way, otherwise I am afraid that base-jdbc and phoenix would diverge.
@kokosing Do you mean support MERGE in base-jdbc module and then let phoenix reuse it? |
Yes. But maybe we can do it other way round too. My second thought is that doing it first in base-jdbc could be premature. |
Yes, My plan is to contributed into Phoenix and Ignite first, then abstract the implementation to the base-jdbc. I was think contributing to the base-jdbc at the beginning of the work as well. |
|
I am really new to this part of Trino. As far as I understand In your code I see that you use $merge_row_id as name, and then you kind of map internal Phoenix ROWKEY column to this synthetic $merge_row_id (in PageSource e.t.c) So my question is why we cannot directly use ROWKEY instead of merge_row_id, so we can kind of force add this column to table handle in For me your current approach looks super helpfull, if we for example want to use some primary key column as $merge_row_id. But if we already have this nice unique identifier - ROWKEY, why just not use it as it is. |
|
@vlad-lyutenko Thank you for watching my code! This is a really good question! I was consider doing like Kudu initially, simple conclusion is that the adjustments won't be less than the current and is hard to extend to other JDBC connectors if follow Kudu is done. The major factor is that while performing operations(SELETE, DELTE, UPDATE) JDBC need to specified the columns while kuduClient can use the api the client supported directly. For the ROWKEY column, Kudu set the value(In Trino) but Phoenix is assigning the value from Phoenix sequence.
Others adjustments may like we need change the ROWKEY type, BIGINT now may not able to store infos about multi primary keys.. |
Big thanks!!! you clarify the things. |
hashhar
left a comment
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.
first pass, looks good. some places I need to take a deeper look.
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcPageSink.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixConnector.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixPageSource.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMergeSink.java
Outdated
Show resolved
Hide resolved
hashhar
left a comment
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.
Looks awesome, can you verify if the MERGE works for non-lowercase tables as well?
Looks good to go other than that.
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMergeSink.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMergeSink.java
Outdated
Show resolved
Hide resolved
|
FYI @lhofhansl , you may be interested in this. Thanks @chenjian2664 for working on this. I'll merge once CI is finished. |
|
For https://github.com/trinodb/trino/actions/runs/4579617258/jobs/8090257129?pr=16693#step:6:5787, I think it's NOT got involved in in this PR. |
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixPageSource.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixPageSource.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixPageSource.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixPageSource.java
Outdated
Show resolved
Hide resolved
plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixPageSource.java
Outdated
Show resolved
Hide resolved
|
Much nicer, thanks @raunaqmorarka for the |
Description
#16661
Additional context and related issues
Release notes
( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
(x) Release notes are required, with the following suggested text: