From d43cf43f7ec2d7ec3c3427c8624d7e3e9c73b838 Mon Sep 17 00:00:00 2001 From: slothever Date: Wed, 9 Aug 2023 16:03:52 +0800 Subject: [PATCH] 1 --- .../java/org/apache/doris/common/util/S3Util.java | 10 +++++++++- .../datasource/property/PropertyConverter.java | 15 ++++++++++++++- .../doris/planner/external/FileQueryScanNode.java | 4 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/S3Util.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/S3Util.java index 6d433d5435a9c2..b944df70d78ffe 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/S3Util.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/S3Util.java @@ -20,6 +20,7 @@ import org.apache.doris.catalog.HdfsResource; import org.apache.doris.common.FeConstants; import org.apache.doris.datasource.credentials.CloudCredential; +import org.apache.doris.datasource.property.constants.S3Properties; import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.fs.Path; @@ -67,6 +68,12 @@ private static boolean isObjStorageUseS3Client(String location) { || location.startsWith(FeConstants.FS_PREFIX_BOS); } + private static boolean isS3EndPoint(String location, Map props) { + // wide check range for the compatibility of s3 properties + return (props.containsKey(S3Properties.ENDPOINT) || props.containsKey(S3Properties.Env.ENDPOINT)) + && isObjStorage(location); + } + /** * The converted path is used for FE to get metadata * @param location origin location @@ -74,7 +81,8 @@ private static boolean isObjStorageUseS3Client(String location) { */ public static String convertToS3IfNecessary(String location, Map props) { LOG.debug("try convert location to s3 prefix: " + location); - if (isObjStorageUseS3Client(location)) { + // include the check for multi locations and in a table, such as both s3 and hdfs are in a table. + if (isS3EndPoint(location, props) || isObjStorageUseS3Client(location)) { int pos = location.indexOf("://"); if (pos == -1) { throw new RuntimeException("No '://' found in location: " + location); diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/property/PropertyConverter.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/property/PropertyConverter.java index 22c82f9169a623..963efb62d62285 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/property/PropertyConverter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/property/PropertyConverter.java @@ -123,11 +123,24 @@ public static Map convertToHadoopFSProperties(Map getTFileType(String location) { return Optional.of(TFileType.FILE_S3); } else if (location.startsWith(FeConstants.FS_PREFIX_HDFS)) { return Optional.of(TFileType.FILE_HDFS); + } else if (location.startsWith(FeConstants.FS_PREFIX_COSN)) { + return Optional.of(TFileType.FILE_HDFS); } else if (location.startsWith(FeConstants.FS_PREFIX_FILE)) { return Optional.of(TFileType.FILE_LOCAL); } else if (location.startsWith(FeConstants.FS_PREFIX_OFS)) { return Optional.of(TFileType.FILE_BROKER); - } else if (location.startsWith(FeConstants.FS_PREFIX_COSN)) { - return Optional.of(TFileType.FILE_BROKER); } else if (location.startsWith(FeConstants.FS_PREFIX_GFS)) { return Optional.of(TFileType.FILE_BROKER); } else if (location.startsWith(FeConstants.FS_PREFIX_JFS)) {