-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Support skip archive for Glue in Iceberg #14336
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
.../trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/GlueClientProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.plugin.iceberg.catalog.glue; | ||
|
||
import com.amazonaws.auth.AWSCredentialsProvider; | ||
import com.amazonaws.services.glue.AWSGlueAsync; | ||
import io.trino.plugin.hive.metastore.glue.GlueHiveMetastoreConfig; | ||
import io.trino.plugin.hive.metastore.glue.GlueMetastoreStats; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Provider; | ||
|
||
import java.util.Optional; | ||
|
||
import static io.trino.plugin.hive.metastore.glue.GlueHiveMetastore.createAsyncGlueClient; | ||
import static java.util.Objects.requireNonNull; | ||
|
||
public class GlueClientProvider | ||
implements Provider<AWSGlueAsync> | ||
{ | ||
private final GlueMetastoreStats stats; | ||
private final AWSCredentialsProvider credentialsProvider; | ||
private final GlueHiveMetastoreConfig glueConfig; // TODO do not keep mutable config instance on a field | ||
private final boolean skipArchive; | ||
|
||
@Inject | ||
public GlueClientProvider( | ||
GlueMetastoreStats stats, | ||
AWSCredentialsProvider credentialsProvider, | ||
GlueHiveMetastoreConfig glueConfig, | ||
IcebergGlueCatalogConfig icebergGlueConfig) | ||
{ | ||
this.stats = requireNonNull(stats, "stats is null"); | ||
this.credentialsProvider = requireNonNull(credentialsProvider, "credentialsProvider is null"); | ||
this.glueConfig = glueConfig; | ||
this.skipArchive = icebergGlueConfig.isSkipArchive(); | ||
} | ||
|
||
@Override | ||
public AWSGlueAsync get() | ||
{ | ||
return createAsyncGlueClient(glueConfig, credentialsProvider, Optional.of(new SkipArchiveRequestHandler(skipArchive)), stats.newRequestMetricsCollector()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/IcebergGlueCatalogConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.plugin.iceberg.catalog.glue; | ||
|
||
import io.airlift.configuration.Config; | ||
import io.airlift.configuration.ConfigDescription; | ||
|
||
public class IcebergGlueCatalogConfig | ||
{ | ||
private boolean skipArchive; | ||
|
||
public boolean isSkipArchive() | ||
{ | ||
return skipArchive; | ||
} | ||
|
||
@Config("iceberg.glue.skip-archive") | ||
@ConfigDescription("Skip archiving an old table version when creating a new version in a commit") | ||
public IcebergGlueCatalogConfig setSkipArchive(boolean skipArchive) | ||
{ | ||
this.skipArchive = skipArchive; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...iceberg/src/main/java/io/trino/plugin/iceberg/catalog/glue/SkipArchiveRequestHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.plugin.iceberg.catalog.glue; | ||
|
||
import com.amazonaws.AmazonWebServiceRequest; | ||
import com.amazonaws.handlers.RequestHandler2; | ||
import com.amazonaws.services.glue.model.CreateDatabaseRequest; | ||
import com.amazonaws.services.glue.model.CreateTableRequest; | ||
import com.amazonaws.services.glue.model.DeleteDatabaseRequest; | ||
import com.amazonaws.services.glue.model.DeleteTableRequest; | ||
import com.amazonaws.services.glue.model.GetDatabaseRequest; | ||
import com.amazonaws.services.glue.model.GetDatabasesRequest; | ||
import com.amazonaws.services.glue.model.GetTableRequest; | ||
import com.amazonaws.services.glue.model.GetTablesRequest; | ||
import com.amazonaws.services.glue.model.UpdateTableRequest; | ||
|
||
public class SkipArchiveRequestHandler | ||
extends RequestHandler2 | ||
{ | ||
private final boolean skipArchive; | ||
|
||
public SkipArchiveRequestHandler(boolean skipArchive) | ||
{ | ||
this.skipArchive = skipArchive; | ||
} | ||
|
||
@Override | ||
public AmazonWebServiceRequest beforeExecution(AmazonWebServiceRequest request) | ||
{ | ||
if (request instanceof UpdateTableRequest updateTableRequest) { | ||
return updateTableRequest.withSkipArchive(skipArchive); | ||
} | ||
if (request instanceof CreateDatabaseRequest || | ||
request instanceof DeleteDatabaseRequest || | ||
request instanceof GetDatabasesRequest || | ||
request instanceof GetDatabaseRequest || | ||
request instanceof CreateTableRequest || | ||
request instanceof DeleteTableRequest || | ||
request instanceof GetTablesRequest || | ||
request instanceof GetTableRequest) { | ||
return request; | ||
} | ||
throw new IllegalArgumentException("Unsupported request: " + request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...berg/src/test/java/io/trino/plugin/iceberg/catalog/glue/TestIcebergGlueCatalogConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.plugin.iceberg.catalog.glue; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Map; | ||
|
||
import static io.airlift.configuration.testing.ConfigAssertions.assertFullMapping; | ||
import static io.airlift.configuration.testing.ConfigAssertions.assertRecordedDefaults; | ||
import static io.airlift.configuration.testing.ConfigAssertions.recordDefaults; | ||
|
||
public class TestIcebergGlueCatalogConfig | ||
{ | ||
@Test | ||
public void testDefaults() | ||
{ | ||
assertRecordedDefaults(recordDefaults(IcebergGlueCatalogConfig.class) | ||
.setSkipArchive(false)); | ||
} | ||
|
||
@Test | ||
public void testExplicitPropertyMapping() | ||
{ | ||
Map<String, String> properties = ImmutableMap.<String, String>builder() | ||
.put("iceberg.glue.skip-archive", "true") | ||
.buildOrThrow(); | ||
|
||
IcebergGlueCatalogConfig expected = new IcebergGlueCatalogConfig() | ||
.setSkipArchive(true); | ||
|
||
assertFullMapping(properties, expected); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why
false
by default?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.
For backward compatibility. I can enable by default if there's no objection.
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.
it's unlikely that most people care about the Glue table versions for Iceberg tables, but it's also not unreasonable that someone uses that.
i think we should have it disabled (false) for now
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.
Agreed, disabled by default makes sense.