Support drop iceberg table when metadata or snapshot is missing and refactor code for delta-lake#15065
Support drop iceberg table when metadata or snapshot is missing and refactor code for delta-lake#15065krvikash wants to merge 4 commits intotrinodb:masterfrom
Conversation
bd6d342 to
604b6c9
Compare
604b6c9 to
2ab0747
Compare
core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/testing/TestingMetadata.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/connector/ConnectorMetadata.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Why is the exception being swallowed?
There was a problem hiding this comment.
Because we do not want to fail when FileNotFoundException exception occurs instead we want to drop the table from metastore and delete table location directory.
plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestTransactionLogAccess.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestTransactionLogAccess.java
Outdated
Show resolved
Hide resolved
4234827 to
eedddc1
Compare
core/trino-spi/src/main/java/io/trino/spi/connector/ConnectorMetadata.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
I'm not positive this will always be a FileNotFoundException. If you're using S3 for example it's probably something like an AmazonServiceException with an error code "Specified key does not exist"
There was a problem hiding this comment.
Modified the exception catch to handle S3 exception. Verified GCP and ADLS exceptions as well.
There was a problem hiding this comment.
I think we should still validate that the table exists here, and throw a TableNotFound exception if it doesn't
There was a problem hiding this comment.
Respective catalog call will take care of validating the table exists.
core/trino-spi/src/main/java/io/trino/spi/StandardErrorCode.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/execution/DropTableTask.java
Outdated
Show resolved
Hide resolved
|
Could you update PR title to reflect Delta Lake connector? |
There was a problem hiding this comment.
We want this method to replace the old one, void dropTable(Session session, TableHandle tableHandle).
So it would be good to
- make ConnectorMetadata change backward compatibility
- apply changes to
DropTableTask
Doing this would reveal that the old drop handles redirections whereas the new drop-by-name cannot do that.
The MetadataManager could follow redirects as needed, but I am concerned this is not the right place to add that logic.
Also, decoupling ConnectorMetadata.redirectTable and ConnectorMetadata.dropTable calls makes it impossible to make a non-racy implementation.
I am leaving towards introducing a non-void return type here, so that drop-by-name can either declare success or return a redirection.
There was a problem hiding this comment.
This looks unresolved. @krvikash @findinpath do you have a plan here?
There was a problem hiding this comment.
perhaps something like this (rough idea, not polished up)
DropResult dropTable(Session session, QualifiedObjectName tableName);
sealed class DropResult
permits DropSuccess, DropRedirectedclass DropSuccess { .. } // singleton (can this be an enum?)records DropRedirected(CatalogSchemaTableName target) {}There was a problem hiding this comment.
When the metadata file is not found, Then we won't be able to get the table properties and validate if the table can be dropped. How to handle this?
7dc64a3 to
649ccd0
Compare
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java
Outdated
Show resolved
Hide resolved
da95d64 to
62b2221
Compare
7cc24be to
7375027
Compare
core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
why is this exception-driven?
what potential exceptions are we ignoring here?
There was a problem hiding this comment.
I want to check the exception which fails with the METADATA_NOT_FOUND error.
There was a problem hiding this comment.
We should probably rethink here the way we obtain the tableName. We don't need actually the full tableHandle for dropping the table, right?
Swallowing the exception gets us to the state of adding the DropResult , DropRedirected and DropSuccess classes and extra logic in MetadataManager.
I think the approach to solve this issue should be thought over.
There was a problem hiding this comment.
I want to check the exception which fails with the
METADATA_NOT_FOUNDerror.
metadata.dropTable must support such case anyway
what does it currently throw?
core/trino-main/src/main/java/io/trino/execution/DropTableTask.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
This looks unresolved. @krvikash @findinpath do you have a plan here?
e127e6e to
038d833
Compare
core/trino-spi/src/main/java/io/trino/spi/connector/ConnectorMetadata.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/StandardErrorCode.java
Outdated
Show resolved
Hide resolved
findepi
left a comment
There was a problem hiding this comment.
"Introduce dropTable SPI method that takes SchemaTableName"
DropTableTask lgtm
please clean up the commit (deprecation, unused class)
038d833 to
bf2bc50
Compare
|
I have written a doc for the approaches we have taken for this PR https://docs.google.com/document/d/1uydrtqfj4S5dhyrQ8JqAsW3fqr1ACXmEvj9MYSpJpLw/ CC: @findepi |
|
sorry for not following up earlier on this. |
bf2bc50 to
2860eee
Compare
|
Rebased and resolved the conflicts. @findepi, I am using using |
2860eee to
f83da0c
Compare
|
Rebased |
f83da0c to
b07a719
Compare
|
Rebased with the master and resolve conflicts. |
b07a719 to
1856081
Compare
|
(rebased resolving a conflict) |
| * | ||
| * @throws RuntimeException if the table cannot be dropped or table handle is no longer valid | ||
| * | ||
| * @deprecated use {@link #dropTable(Session, QualifiedObjectName)} |
There was a problem hiding this comment.
This overload is a dead code now, no need for keeping it (as deprecated)
| } | ||
|
|
||
| @Test(groups = {HIVE_ICEBERG_REDIRECTIONS, PROFILE_SPECIFIC_TESTS}) | ||
| public void testDropTableWithMissingMetadataFile() |
There was a problem hiding this comment.
Would it make sense to have it tested outside of PTs?
Description
Fixes #12318
This PR Includes below:
SPI:
Introduced new SPI method
dropTablewhich takesSchemaTableName. It is the connector's responsibility to implement the method.Note:
dropTablewith table handle deprecation/removal will be taken care in new PRIceberg connector:
Q: What if latest manifest file or snapshot file does not exist and data files referenced by TableMetadata located in different locations?
Delta-Lake connector:
dropTablewithSchemaTableNamein case delta log does not existmetadataEntrynon-optional in DeltaLakeTableHandleNon-technical explanation
NA
Release notes
( ) This is not user-visible or docs only and no release notes are required.
(X) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: