Avoid no-op Iceberg table snapshot if DML doesn't change table state#12412
Conversation
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java
Outdated
Show resolved
Hide resolved
4ffb3f8 to
02c4940
Compare
plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java
Outdated
Show resolved
Hide resolved
02c4940 to
fa4a6d5
Compare
fa4a6d5 to
31f0630
Compare
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
I think we could change this to
// avoid empty snapshot for existing tables
if (commitTasks.isEmpty() && (table.currentSnapshot() != null)) {Then we don't need the special case in finishCreateTable().
There was a problem hiding this comment.
Yes, this could be done indeed as you mentioned.
This has been actually the initial version of the code in the PR.
However, the code would be a bit more difficult to understand with the handling for this special case in finishInsert so we've decided to go further with adding the handling for empty CTAS into finishCreateTable.
Related discussion:
There was a problem hiding this comment.
Shouldn't this check happen before instantiating Type[] partitionColumnTypes ?
There was a problem hiding this comment.
I moved the check at the beginning of the method. Thanks for bringing this up.
plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java
Outdated
Show resolved
Hide resolved
|
@findinpath please update @alexjo2144 please review after the update |
31f0630 to
306f730
Compare
306f730 to
1f676b1
Compare
|
@findinpath do you want to suggest RN entry? |
I think that the change in this PR is rather minor for Iceberg functionality and probably is not worth mentioning in the release notes. I added however the following RN line the PR description.
Up to you @findepi whether this should get included in the RN. |
Description
This PR avoids creating an Iceberg snapshot when dealing with a DML statement that does not affect the contents of the Iceberg table.
e.g. :
NOTE however that a CTAS statement that corresponds to an empty
SELECTwill be obviously recorded as a table snapshot because it creates the table.Improvement
Iceberg connector
Avoid creating a snapshot for a table when dealing with an empty DML (INSERT, UPDATE, DELETE) statement.
Related issues, pull requests, and links
Fixes #12319
Documentation
(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
(x) No release notes entries required.
( ) Release notes entries required with the following suggested text: