-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#4264] feat(iceberg): support access S3 with static access key for I…
…ceberg REST server and Gravitino Iceberg catalog (#4250) ### What changes were proposed in this pull request? 1. support using static access-key-id and secret-access-key to access S3 data for iceberg rest server and gravitino iceberg catalog 2. refactor the code to reuse the iceberg catalog transform logic for connector and Iceberg rest server and Iceberg catalog 3. add configuration to manage the s3 access key ### Why are the changes needed? Fix: #4264 ### Does this PR introduce _any_ user-facing change? yes, add some document ### How was this patch tested? I tested Iceberg REST server and Iceberg catalog with `jdbc` catalog backend and `hive` catalog backend to access S3 data.
- Loading branch information
Showing
16 changed files
with
321 additions
and
188 deletions.
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
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
69 changes: 69 additions & 0 deletions
69
.../src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergPropertiesUtils.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,69 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.apache.gravitino.catalog.lakehouse.iceberg; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class IcebergPropertiesUtils { | ||
|
||
// Map that maintains the mapping of keys in Gravitino to that in Iceberg, for example, users | ||
// will only need to set the configuration 'catalog-backend' in Gravitino and Gravitino will | ||
// change it to `catalogType` automatically and pass it to Iceberg. | ||
public static final Map<String, String> GRAVITINO_CONFIG_TO_ICEBERG; | ||
|
||
static { | ||
Map<String, String> map = new HashMap(); | ||
map.put(IcebergConstants.CATALOG_BACKEND, IcebergConstants.CATALOG_BACKEND); | ||
map.put(IcebergConstants.GRAVITINO_JDBC_DRIVER, IcebergConstants.GRAVITINO_JDBC_DRIVER); | ||
map.put(IcebergConstants.GRAVITINO_JDBC_USER, IcebergConstants.ICEBERG_JDBC_USER); | ||
map.put(IcebergConstants.GRAVITINO_JDBC_PASSWORD, IcebergConstants.ICEBERG_JDBC_PASSWORD); | ||
map.put(IcebergConstants.URI, IcebergConstants.URI); | ||
map.put(IcebergConstants.WAREHOUSE, IcebergConstants.WAREHOUSE); | ||
map.put(IcebergConstants.CATALOG_BACKEND_NAME, IcebergConstants.CATALOG_BACKEND_NAME); | ||
map.put(IcebergConstants.IO_IMPL, IcebergConstants.IO_IMPL); | ||
map.put(IcebergConstants.GRAVITINO_S3_ENDPOINT, IcebergConstants.ICEBERG_S3_ENDPOINT); | ||
map.put(IcebergConstants.GRAVITINO_S3_REGION, IcebergConstants.AWS_S3_REGION); | ||
map.put(IcebergConstants.GRAVITINO_S3_ACCESS_KEY_ID, IcebergConstants.ICEBERG_S3_ACCESS_KEY_ID); | ||
map.put( | ||
IcebergConstants.GRAVITINO_S3_SECRET_ACCESS_KEY, | ||
IcebergConstants.ICEBERG_S3_SECRET_ACCESS_KEY); | ||
GRAVITINO_CONFIG_TO_ICEBERG = Collections.unmodifiableMap(map); | ||
} | ||
|
||
/** | ||
* Converts Gravitino properties to Iceberg catalog properties, the common transform logic shared | ||
* by Spark connector, Iceberg REST server, Gravitino Iceberg catalog. | ||
* | ||
* @param gravitinoProperties a map of Gravitino configuration properties. | ||
* @return a map containing Iceberg catalog properties. | ||
*/ | ||
public static Map<String, String> toIcebergCatalogProperties( | ||
Map<String, String> gravitinoProperties) { | ||
Map<String, String> icebergProperties = new HashMap<>(); | ||
gravitinoProperties.forEach( | ||
(key, value) -> { | ||
if (GRAVITINO_CONFIG_TO_ICEBERG.containsKey(key)) { | ||
icebergProperties.put(GRAVITINO_CONFIG_TO_ICEBERG.get(key), value); | ||
} | ||
}); | ||
return icebergProperties; | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.