Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions fe/fe-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ under the License.
<doris.thirdparty>${basedir}/../../thirdparty</doris.thirdparty>
<fe_ut_parallel>1</fe_ut_parallel>
<antlr4.version>4.9.3</antlr4.version>
<awssdk.version>2.17.257</awssdk.version>
<awssdk.version>2.20.131</awssdk.version>
<huaweiobs.version>3.1.1-hw-46</huaweiobs.version>
<tencentcos.version>3.3.5</tencentcos.version>
</properties>
Expand Down Expand Up @@ -542,7 +542,11 @@ under the License.
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-aws</artifactId>
</dependency>

<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-aws-bundle</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.paimon</groupId>
<artifactId>paimon-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

import org.apache.hadoop.fs.s3a.Constants;
import org.apache.iceberg.CatalogProperties;
import org.apache.iceberg.aws.AwsProperties;
import org.apache.iceberg.aws.glue.GlueCatalog;
import org.apache.iceberg.aws.s3.S3FileIOProperties;
import org.apache.iceberg.catalog.Namespace;

import java.util.List;
Expand Down Expand Up @@ -55,7 +55,7 @@ protected void initLocalObjectsImpl() {
// read from converted s3 endpoint or default by BE s3 endpoint
String endpoint = catalogProperties.getOrDefault(Constants.ENDPOINT,
catalogProperties.get(S3Properties.Env.ENDPOINT));
catalogProperties.putIfAbsent(AwsProperties.S3FILEIO_ENDPOINT, endpoint);
catalogProperties.putIfAbsent(S3FileIOProperties.ENDPOINT, endpoint);

glueCatalog.initialize(icebergCatalogType, catalogProperties);
catalog = glueCatalog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,24 @@
package org.apache.doris.datasource.iceberg;

import org.apache.doris.datasource.CatalogProperty;
import org.apache.doris.datasource.iceberg.rest.DorisIcebergRestResolvedIO;
import org.apache.doris.datasource.property.PropertyConverter;
import org.apache.doris.datasource.property.constants.S3Properties;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.s3a.Constants;
import org.apache.iceberg.CatalogProperties;
import org.apache.iceberg.rest.RESTCatalog;
import org.apache.iceberg.CatalogUtil;
import org.apache.iceberg.aws.AwsClientProperties;
import org.apache.iceberg.aws.s3.S3FileIO;
import org.apache.iceberg.aws.s3.S3FileIOProperties;

import java.util.HashMap;
import java.util.Map;

public class IcebergRestExternalCatalog extends IcebergExternalCatalog {

public IcebergRestExternalCatalog(long catalogId, String name, String resource, Map<String, String> props,
String comment) {
String comment) {
super(catalogId, name, comment);
props = PropertyConverter.convertToMetaProperties(props);
catalogProperty = new CatalogProperty(resource, props);
Expand All @@ -42,18 +44,12 @@ public IcebergRestExternalCatalog(long catalogId, String name, String resource,
@Override
protected void initLocalObjectsImpl() {
icebergCatalogType = ICEBERG_REST;
Map<String, String> restProperties = new HashMap<>();
String restUri = catalogProperty.getProperties().getOrDefault(CatalogProperties.URI, "");
restProperties.put(CatalogProperties.URI, restUri);
restProperties.put(CatalogProperties.FILE_IO_IMPL, DorisIcebergRestResolvedIO.class.getName());
restProperties.putAll(catalogProperty.getProperties());

Configuration conf = replaceS3Properties(getConfiguration());

RESTCatalog restCatalog = new RESTCatalog();
restCatalog.setConf(conf);
restCatalog.initialize(icebergCatalogType, restProperties);
catalog = restCatalog;
catalog = CatalogUtil.buildIcebergCatalog(icebergCatalogType,
convertToRestCatalogProperties(),
conf);
}

private Configuration replaceS3Properties(Configuration conf) {
Expand All @@ -71,4 +67,30 @@ private Configuration replaceS3Properties(Configuration conf) {
catalogProperties.getOrDefault(Constants.S3GUARD_CONSISTENCY_RETRY_LIMIT, "1"));
return conf;
}

private Map<String, String> convertToRestCatalogProperties() {

Map<String, String> props = catalogProperty.getProperties();
Map<String, String> restProperties = new HashMap<>(props);
restProperties.put(CatalogProperties.FILE_IO_IMPL, S3FileIO.class.getName());
restProperties.put(CatalogUtil.ICEBERG_CATALOG_TYPE, CatalogUtil.ICEBERG_CATALOG_TYPE_REST);
String restUri = props.getOrDefault(CatalogProperties.URI, "");
restProperties.put(CatalogProperties.URI, restUri);
if (props.containsKey(S3Properties.ENDPOINT)) {
restProperties.put(S3FileIOProperties.ENDPOINT, props.get(S3Properties.ENDPOINT));
}
if (props.containsKey(S3Properties.ACCESS_KEY)) {
restProperties.put(S3FileIOProperties.ACCESS_KEY_ID, props.get(S3Properties.ACCESS_KEY));
}
if (props.containsKey(S3Properties.SECRET_KEY)) {
restProperties.put(S3FileIOProperties.SECRET_ACCESS_KEY, props.get(S3Properties.SECRET_KEY));
}
if (props.containsKey(S3Properties.REGION)) {
restProperties.put(AwsClientProperties.CLIENT_REGION, props.get(S3Properties.REGION));
}
if (props.containsKey(PropertyConverter.USE_PATH_STYLE)) {
restProperties.put(S3FileIOProperties.PATH_STYLE_ACCESS, props.get(PropertyConverter.USE_PATH_STYLE));
}
return restProperties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,19 @@

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.iceberg.ClientPool;
import org.apache.iceberg.exceptions.NoSuchTableException;
import org.apache.iceberg.hive.HiveTableOperations;
import org.apache.iceberg.io.FileIO;
import shade.doris.hive.org.apache.thrift.TException;

public class DLFTableOperations extends HiveTableOperations {

private final ClientPool<IMetaStoreClient, TException> metaClients;
private final String database;
private final String tableName;
private final int metadataRefreshMaxRetries;

public DLFTableOperations(Configuration conf,
ClientPool<IMetaStoreClient, TException> metaClients,
FileIO fileIO,
String catalogName,
String database,
String table) {
super(conf, metaClients, fileIO, catalogName, database, table);
this.metaClients = metaClients;
this.database = database;
this.tableName = table;
metadataRefreshMaxRetries = conf.getInt(
"iceberg.hive.metadata-refresh-max-retries", 2);
}

@Override
protected void doRefresh() {
String metadataLocation = null;
try {
Table table = metaClients.run(client -> client.getTable(database, tableName));
metadataLocation = table.getParameters().get(METADATA_LOCATION_PROP);
} catch (NoSuchObjectException e) {
if (currentMetadataLocation() != null) {
throw new NoSuchTableException("No such table: %s.%s", database, tableName);
}
} catch (TException e) {
String errMsg = String.format("Failed to get table info from metastore %s.%s", database, tableName);
throw new RuntimeException(errMsg, e);

} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("Interrupted during refresh", e);
}
refreshFromMetadataLocation(metadataLocation, metadataRefreshMaxRetries);
}
}
Loading