-
Notifications
You must be signed in to change notification settings - Fork 3k
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 support for table rename for delta lake with glue #13707
Add support for table rename for delta lake with glue #13707
Conversation
42928ae
to
cdd7429
Compare
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.
Just to be clear, this will not move any data files?
@@ -288,6 +289,8 @@ | |||
private final boolean deleteSchemaLocationsFallback; | |||
private final boolean useUniqueTableLocation; | |||
|
|||
private final MetastoreTypeConfig metastoreTypeConfig; |
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.
Store the type itself, not the config
private final MetastoreTypeConfig metastoreTypeConfig; | |
private final String metastoreType; |
@@ -1992,7 +1997,7 @@ public void renameTable(ConnectorSession session, ConnectorTableHandle tableHand | |||
DeltaLakeTableHandle handle = (DeltaLakeTableHandle) tableHandle; | |||
Table table = metastore.getTable(handle.getSchemaName(), handle.getTableName()) | |||
.orElseThrow(() -> new TableNotFoundException(handle.getSchemaTableName())); | |||
if (table.getTableType().equals(MANAGED_TABLE.name())) { | |||
if (table.getTableType().equals(MANAGED_TABLE.name()) && !metastoreTypeConfig.getMetastoreType().equals("glue")) { |
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.
equalsIgnoreCase
cdd7429
to
8c4467b
Compare
This failing suite is not related. It has been failing before on master https://github.com/trinodb/trino/runs/7976696676?check_suite_focus=true |
It should not |
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 update io.trino.plugin.hive.metastore.glue.TestHiveGlueMetastore#testRenameTable
?
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/main/java/io/trino/plugin/deltalake/DeltaLakeMetadataFactory.java
Outdated
Show resolved
Hide resolved
...lta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeRenameToWithGlueMetastore.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java
Outdated
Show resolved
Hide resolved
Sorry I didn't notice this method |
e0e52eb
to
4782b6c
Compare
failure doesn't seem to be related |
@@ -1996,7 +1999,8 @@ public void renameTable(ConnectorSession session, ConnectorTableHandle tableHand | |||
DeltaLakeTableHandle handle = (DeltaLakeTableHandle) tableHandle; | |||
Table table = metastore.getTable(handle.getSchemaName(), handle.getTableName()) | |||
.orElseThrow(() -> new TableNotFoundException(handle.getSchemaTableName())); | |||
if (table.getTableType().equals(MANAGED_TABLE.name())) { | |||
if (table.getTableType().equals(MANAGED_TABLE.name()) && | |||
!(metastoreType.equalsIgnoreCase("glue") || metastoreType.equalsIgnoreCase("file"))) { |
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.
Maybe include the metastore type in the exception msg
@@ -98,6 +102,7 @@ public DeltaLakeMetadataFactory( | |||
this.perTransactionMetastoreCacheMaximumSize = deltaLakeConfig.getPerTransactionMetastoreCacheMaximumSize(); | |||
this.deleteSchemaLocationsFallback = deltaLakeConfig.isDeleteSchemaLocationsFallback(); | |||
this.useUniqueTableLocation = deltaLakeConfig.isUniqueTableLocation(); | |||
this.metastoreTypeConfig = requireNonNull(metastoreTypeConfig, "metastoreTypeConfig is null"); |
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.
Reason we do this is that config classes are mutable and the metastore type cannot be changed dynamically. Realistically, this is not usually a problem but better to do it this way.
this.metastoreTypeConfig = requireNonNull(metastoreTypeConfig, "metastoreTypeConfig is null"); | |
requireNonNull(metastoreTypeConfig, "metastoreTypeConfig is null"); | |
this.metastoreType = metastoreTypeConfig.getMetastoreType(); |
public class TestDeltaLakeRenameToWithGlueMetastore | ||
extends AbstractTestQueryFramework | ||
{ | ||
protected static final String SCHEMA = "test_tables_with_custom_location" + randomTableSuffix(); |
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.
protected static final String SCHEMA = "test_tables_with_custom_location" + randomTableSuffix(); | |
protected static final String SCHEMA = "test_delta_lake_rename_to_with_glue_" + randomTableSuffix(); |
plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java
Show resolved
Hide resolved
1f9c62e
to
a93d827
Compare
@ebyhr I think this is a new test that is failing, it should not be related to my change I think you added it recently could you please take a look ? |
Looking the failure. I will send a PR today. |
4c85271
to
6f47296
Compare
@ebyhr can we merge this or do i need more changes? |
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadataFactory.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java
Show resolved
Hide resolved
plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/glue/TestHiveGlueMetastore.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java
Show resolved
Hide resolved
We never set them anywhere, for Iceberg we don't copy them either, what is more I don't see a way to obtain them. |
bc2e89d
to
c92f31f
Compare
Even if our connectors don't set partition indexes, users can directly set it in Glue and such index might be used when finding partitions in Hive tables.
We need to call Anyway, you added a logic to deny Glue metastore in |
Oh that makes sense, I didn't know that, thanks.
Yes because it was not my intention to turn it on for Hive. I think that it would be hard as for hive it would make sense to actually move data to new location and for DeltaLAke and Iceberg we don't move that so it would be a totally different story |
...st/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeRenameToWithGlueMetastore.java
Show resolved
Hide resolved
...st/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeRenameToWithGlueMetastore.java
Outdated
Show resolved
Hide resolved
...st/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeRenameToWithGlueMetastore.java
Outdated
Show resolved
Hide resolved
c92f31f
to
30423e8
Compare
30423e8
to
43b174a
Compare
Merged, thanks! |
Description
new feature
a connector
ALTER TABLE RENAME TO can be used with glue as a metastore for delta lake
Related issues, pull requests, and links
Fixes: #12985
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
( ) No release notes entries required.
(x) Release notes entries required with the following suggested text: