Skip to content
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

Add DELETE and UPDATE to trino-base-jdbc #6993

Open
lhofhansl opened this issue Feb 22, 2021 · 8 comments
Open

Add DELETE and UPDATE to trino-base-jdbc #6993

lhofhansl opened this issue Feb 22, 2021 · 8 comments

Comments

@lhofhansl
Copy link
Member

lhofhansl commented Feb 22, 2021

Looking at the code involves something like the following:

  • use getPageSourceProvider instead of getRecordSetProvider in JdbcConnector and return an UpdatablePageSource (probably a class that extends RecordPageSource and wraps the existing ResultSet)
  • Implement the UpdatablePageSource methods (updateRows, deleteRows, etc)
  • Figure out the RowId column handle - for JDBC just the PK columns
  • Add getUpdateRowIdColumnHandle and getDeleteRowIdColumnHandle to JdbcMetadata
  • Add buildDeleteSql and buildUpdateSql to JdbcClient and use those from the UpdatablePageSource to perform the writes.
  • (And probably a bunch of more stuff...)

Once it's added to trino-base-jdbc it can be add the the Postgres, MySQL, Phoenix, etc, connectors.

Note sure I'll find time to do this, filing in case someones else is interested. :)

Relates to #5275

@findepi
Copy link
Member

findepi commented Feb 23, 2021

There is a PR for DELETE, using a different approach than outlined here.
#6287

@kokosing
Copy link
Member

I think we can also leverage same approach as in #6287 for UPDATE.

Today I am not sure if support for arbitrary UPDATE and DELETE is very needed for JDBC connectors. WDYT?

@lhofhansl
Copy link
Member Author

lhofhansl commented Feb 23, 2021

I was searching here for UPDATE (forgot to search for DELETE) my apologies.

I can't comment on whether it's generally important. Here we were debating whether we can use Trino as our (almost) general SQL frontend - since we have OLTP type data source (Oracle, PostgreSQL, Phoenix, etc) as well as OLAP (Hive and Iceberg tables). While there are other considerations as well, one counter point was that we cannot issue DELETEs or UPDATEs to our OLTP data sources. I'd argue it's just as important as adding DELETE and UPDATE to the Hive connector.

If #6287 is easier to do, let's do it that way. I was going by the added UpdatableDataSource and wanted to see how to leverage that.

@13250709979
Copy link

Looking at the code involves something like the following:

  • use getPageSourceProvider instead of getRecordSetProvider in JdbcConnector and return an UpdatablePageSource (probably a class that extends RecordPageSource and wraps the existing ResultSet)
  • Implement the UpdatablePageSource methods (updateRows, deleteRows, etc)
  • Figure out the RowId column handle - for JDBC just the PK columns
  • Add getUpdateRowIdColumnHandle and getDeleteRowIdColumnHandle to JdbcMetadata
  • Add buildDeleteSql and buildUpdateSql to JdbcClient and use those from the UpdatablePageSource to perform the writes.
  • (And probably a bunch of more stuff...)

Once it's added to trino-base-jdbc it can be add the the Postgres, MySQL, Phoenix, etc, connectors.

Note sure I'll find time to do this, filing in case someones else is interested. :)

Relates to #5275
Recently, I want to implement the delete and update statements of JDBC. Can you provide a more detailed modification scheme? thank you

@kokosing
Copy link
Member

kokosing commented Jul 2, 2021

@lhofhansl Since DELETE is merged, would you be willing to work on UPDATE?

@findepi
Copy link
Member

findepi commented Jul 12, 2021

per

throw new TrinoException(NOT_SUPPORTED, "Unsupported delete");

I think it would be valuable to first extend DELETE to support cases when the delete predicate cannot be fully pushed down (eg LIKE, subquery, a function call, something requiring coercions, etc.)

@Jackhuihui
Copy link

@lhofhansl Since DELETE is merged, would you be willing to work on UPDATE?

UPDATE to trino-base-jdbc Still not supported,I think its a common use function @lhofhansl

@kokosing
Copy link
Member

kokosing commented Mar 15, 2023

There is work already in progress for UPDATE, see #16445

CC: @vlad-lyutenko

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants