-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add read support for S3 Tables in Iceberg #24815
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
Merged
+794
−7
Merged
Changes from all commits
Commits
Show all changes
3 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 hidden or 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
This file contains hidden or 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,30 @@ | ||
| # Iceberg Connector Developer Notes | ||
|
|
||
| Steps to create TPCH tables on S3 Tables: | ||
| 1. Set `AWS_REGION`, `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. | ||
| 2. Replace placeholders in the following command and run it: | ||
| ```sh | ||
| ./spark-sql \ | ||
| --packages org.apache.iceberg:iceberg-spark-runtime-3.5_2.12:1.6.1,software.amazon.awssdk:bundle:2.20.10,software.amazon.s3tables:s3-tables-catalog-for-iceberg-runtime:0.1.3,org.apache.kyuubi:kyuubi-spark-connector-tpch_2.12:1.8.0 \ | ||
| --conf spark.sql.catalog.s3tablesbucket=org.apache.iceberg.spark.SparkCatalog \ | ||
| --conf spark.sql.catalog.s3tablesbucket.catalog-impl=software.amazon.s3tables.iceberg.S3TablesCatalog \ | ||
| --conf spark.sql.catalog.s3tablesbucket.warehouse=arn:aws:s3tables:{region}:{account-id}:bucket/{bucket-name} \ | ||
| --conf spark.sql.extensions=org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions \ | ||
| --conf spark.sql.catalog.tpch=org.apache.kyuubi.spark.connector.tpch.TPCHCatalog | ||
| ``` | ||
|
|
||
| 3. Run the following command to create TPCH tables: | ||
| ```sql | ||
| CREATE TABLE s3tablesbucket.tpch.nation AS SELECT | ||
| n_nationkey AS nationkey, | ||
| n_name AS name, | ||
| n_regionkey AS regionkey, | ||
| n_comment AS comment | ||
| FROM tpch.tiny.nation; | ||
|
|
||
| CREATE TABLE s3tablesbucket.tpch.region AS SELECT | ||
| r_regionkey AS regionkey, | ||
| r_name AS name, | ||
| r_comment AS comment | ||
| FROM tpch.tiny.region; | ||
| ``` | ||
This file contains hidden or 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
22 changes: 22 additions & 0 deletions
22
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/AwsProperties.java
This file contains hidden or 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,22 @@ | ||
| /* | ||
| * 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.rest; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| @FunctionalInterface | ||
| public interface AwsProperties | ||
| { | ||
ebyhr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Map<String, String> get(); | ||
| } | ||
This file contains hidden or 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 | ||
|---|---|---|---|---|
|
|
@@ -47,6 +47,8 @@ public enum SessionType | |||
| private Security security = Security.NONE; | ||||
| private SessionType sessionType = SessionType.NONE; | ||||
| private boolean vendedCredentialsEnabled; | ||||
| private boolean viewEndpointsEnabled = true; | ||||
| private boolean sigV4Enabled; | ||||
| private boolean caseInsensitiveNameMatching; | ||||
| private Duration caseInsensitiveNameMatchingCacheTtl = new Duration(1, MINUTES); | ||||
|
|
||||
|
|
@@ -146,6 +148,32 @@ public IcebergRestCatalogConfig setVendedCredentialsEnabled(boolean vendedCreden | |||
| return this; | ||||
| } | ||||
|
|
||||
| public boolean isViewEndpointsEnabled() | ||||
| { | ||||
| return viewEndpointsEnabled; | ||||
| } | ||||
|
|
||||
| @Config("iceberg.rest-catalog.view-endpoints-enabled") | ||||
| @ConfigDescription("Enable view endpoints") | ||||
| public IcebergRestCatalogConfig setViewEndpointsEnabled(boolean viewEndpointsEnabled) | ||||
| { | ||||
| this.viewEndpointsEnabled = viewEndpointsEnabled; | ||||
| return this; | ||||
| } | ||||
|
|
||||
| public boolean isSigV4Enabled() | ||||
| { | ||||
| return sigV4Enabled; | ||||
| } | ||||
|
|
||||
| @Config("iceberg.rest-catalog.sigv4-enabled") | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume there would be a separate ticket for updating the docs
|
||||
| @ConfigDescription("Enable AWS Signature version 4 (SigV4)") | ||||
| public IcebergRestCatalogConfig setSigV4Enabled(boolean sigV4Enabled) | ||||
| { | ||||
| this.sigV4Enabled = sigV4Enabled; | ||||
| return this; | ||||
| } | ||||
|
|
||||
| public boolean isCaseInsensitiveNameMatching() | ||||
| { | ||||
| return caseInsensitiveNameMatching; | ||||
|
|
||||
This file contains hidden or 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
38 changes: 38 additions & 0 deletions
38
...erg/src/main/java/io/trino/plugin/iceberg/catalog/rest/IcebergRestCatalogSigV4Config.java
This file contains hidden or 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,38 @@ | ||
| /* | ||
| * 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.rest; | ||
|
|
||
| import io.airlift.configuration.Config; | ||
| import io.airlift.configuration.ConfigDescription; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import org.apache.iceberg.aws.AwsProperties; | ||
|
|
||
| public class IcebergRestCatalogSigV4Config | ||
| { | ||
| private String signingName = AwsProperties.REST_SIGNING_NAME_DEFAULT; | ||
|
|
||
| @NotNull | ||
| public String getSigningName() | ||
| { | ||
| return signingName; | ||
| } | ||
|
|
||
| @Config("iceberg.rest-catalog.signing-name") | ||
| @ConfigDescription("AWS SigV4 signing service name") | ||
| public IcebergRestCatalogSigV4Config setSigningName(String signingName) | ||
ebyhr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| this.signingName = signingName; | ||
| return this; | ||
| } | ||
| } | ||
52 changes: 52 additions & 0 deletions
52
.../trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/SigV4AwsProperties.java
This file contains hidden or 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,52 @@ | ||
| /* | ||
| * 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.rest; | ||
|
|
||
| import com.google.common.collect.ImmutableMap; | ||
| import com.google.inject.Inject; | ||
| import io.trino.filesystem.s3.S3FileSystemConfig; | ||
| import io.trino.plugin.iceberg.IcebergSecurityConfig; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import static com.google.common.base.Preconditions.checkArgument; | ||
| import static io.trino.plugin.iceberg.IcebergSecurityConfig.IcebergSecurity.READ_ONLY; | ||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| public class SigV4AwsProperties | ||
| implements AwsProperties | ||
| { | ||
| private final Map<String, String> properties; | ||
|
|
||
| @Inject | ||
| public SigV4AwsProperties(IcebergSecurityConfig securityConfig, IcebergRestCatalogSigV4Config sigV4Config, S3FileSystemConfig s3Config) | ||
| { | ||
| // TODO https://github.com/trinodb/trino/issues/24916 Allow write operations with SigV4 | ||
| checkArgument(securityConfig.getSecuritySystem() == READ_ONLY, "Read-only security system is required"); | ||
| this.properties = ImmutableMap.<String, String>builder() | ||
| .put("rest.sigv4-enabled", "true") | ||
| .put("rest.signing-name", sigV4Config.getSigningName()) | ||
| .put("rest.access-key-id", requireNonNull(s3Config.getAwsAccessKey(), "s3.aws-access-key is null")) | ||
| .put("rest.secret-access-key", requireNonNull(s3Config.getAwsSecretKey(), "s3.aws-secret-key is null")) | ||
| .put("rest.signing-region", requireNonNull(s3Config.getRegion(), "s3.region is null")) | ||
| .put("rest-metrics-reporting-enabled", "false") | ||
| .buildOrThrow(); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<String, String> get() | ||
| { | ||
| return properties; | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
...src/test/java/io/trino/plugin/iceberg/catalog/rest/TestIcebergRestCatalogSigV4Config.java
This file contains hidden or 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.rest; | ||
|
|
||
| import com.google.common.collect.ImmutableMap; | ||
| import org.junit.jupiter.api.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; | ||
|
|
||
| final class TestIcebergRestCatalogSigV4Config | ||
| { | ||
| @Test | ||
| void testDefaults() | ||
| { | ||
| assertRecordedDefaults(recordDefaults(IcebergRestCatalogSigV4Config.class) | ||
| .setSigningName("execute-api")); | ||
| } | ||
|
|
||
| @Test | ||
| void testExplicitPropertyMappings() | ||
| { | ||
| Map<String, String> properties = ImmutableMap.<String, String>builder() | ||
| .put("iceberg.rest-catalog.signing-name", "glue") | ||
| .buildOrThrow(); | ||
|
|
||
| IcebergRestCatalogSigV4Config expected = new IcebergRestCatalogSigV4Config() | ||
| .setSigningName("glue"); | ||
|
|
||
| assertFullMapping(properties, expected); | ||
| } | ||
| } |
Oops, something went wrong.
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.
do we want to document how to set up S3 table user, lake formation permissions etc.? at least some docs to follow in to set up the environment.
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.
Yes, but it's purely AWS setup information, not specific to our test. It would nice to add a link to the official documentation once AWS publishes it.