Skip to content
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

[Fix](PaimonCatalog) fix the problem that paimon catalog can not access to OSS-HDFS #42585 #44149

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
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,19 @@ private LocationPath(String originLocation, Map<String, String> props, boolean c
tmpLocation = convertPath ? convertToS3(tmpLocation) : tmpLocation;
break;
case FeConstants.FS_PREFIX_OSS:
if (isHdfsOnOssEndpoint(tmpLocation)) {
String endpoint = "";
if (props.containsKey(OssProperties.ENDPOINT)) {
endpoint = props.get(OssProperties.ENDPOINT);
if (endpoint.startsWith(OssProperties.OSS_PREFIX)) {
// may use oss.oss-cn-beijing.aliyuncs.com
endpoint = endpoint.replace(OssProperties.OSS_PREFIX, "");
}
} else if (props.containsKey(S3Properties.ENDPOINT)) {
endpoint = props.get(S3Properties.ENDPOINT);
} else if (props.containsKey(S3Properties.Env.ENDPOINT)) {
endpoint = props.get(S3Properties.Env.ENDPOINT);
}
if (isHdfsOnOssEndpoint(endpoint)) {
this.scheme = Scheme.OSS_HDFS;
} else {
if (useS3EndPoint(props)) {
Expand Down Expand Up @@ -398,7 +410,7 @@ private static String normalizedLakefsPath(String location) {
}
}

private FileSystemType getFileSystemType() {
public FileSystemType getFileSystemType() {
FileSystemType fsType;
switch (scheme) {
case S3:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

package org.apache.doris.datasource.paimon;

import org.apache.doris.common.util.LocationPath;
import org.apache.doris.datasource.property.PropertyConverter;
import org.apache.doris.datasource.property.constants.CosProperties;
import org.apache.doris.datasource.property.constants.ObsProperties;
import org.apache.doris.datasource.property.constants.OssProperties;
import org.apache.doris.datasource.property.constants.PaimonProperties;

import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -53,12 +55,17 @@ protected void setPaimonCatalogOptions(Map<String, String> properties, Map<Strin
options.put(PaimonProperties.PAIMON_S3_SECRET_KEY,
properties.get(PaimonProperties.PAIMON_S3_SECRET_KEY));
} else if (properties.containsKey(PaimonProperties.PAIMON_OSS_ENDPOINT)) {
options.put(PaimonProperties.PAIMON_OSS_ENDPOINT,
properties.get(PaimonProperties.PAIMON_OSS_ENDPOINT));
options.put(PaimonProperties.PAIMON_OSS_ACCESS_KEY,
properties.get(PaimonProperties.PAIMON_OSS_ACCESS_KEY));
options.put(PaimonProperties.PAIMON_OSS_SECRET_KEY,
properties.get(PaimonProperties.PAIMON_OSS_SECRET_KEY));
boolean hdfsEnabled = Boolean.parseBoolean(properties.getOrDefault(
OssProperties.OSS_HDFS_ENABLED, "false"));
if (!LocationPath.isHdfsOnOssEndpoint(properties.get(PaimonProperties.PAIMON_OSS_ENDPOINT))
&& !hdfsEnabled) {
options.put(PaimonProperties.PAIMON_OSS_ENDPOINT,
properties.get(PaimonProperties.PAIMON_OSS_ENDPOINT));
options.put(PaimonProperties.PAIMON_OSS_ACCESS_KEY,
properties.get(PaimonProperties.PAIMON_OSS_ACCESS_KEY));
options.put(PaimonProperties.PAIMON_OSS_SECRET_KEY,
properties.get(PaimonProperties.PAIMON_OSS_SECRET_KEY));
}
} else if (properties.containsKey(CosProperties.ENDPOINT)) {
options.put(PaimonProperties.PAIMON_S3_ENDPOINT,
properties.get(CosProperties.ENDPOINT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.doris.catalog.HdfsResource;
import org.apache.doris.common.util.LocationPath.Scheme;
import org.apache.doris.datasource.property.constants.OssProperties;
import org.apache.doris.fs.FileSystemType;

import org.junit.jupiter.api.Assertions;
Expand Down Expand Up @@ -119,13 +120,14 @@ public void testOSSLocationConvert() {
Assertions.assertTrue(beLocation.startsWith("s3://"));
Assertions.assertEquals(LocationPath.getFSIdentity(beLocation, null).first, FileSystemType.S3);

rangeProps.put(OssProperties.ENDPOINT, "oss-dls.aliyuncs.com");
locationPath = new LocationPath("oss://test.oss-dls.aliyuncs.com/path", rangeProps);
// FE
Assertions.assertTrue(locationPath.get().startsWith("oss://test.oss-dls.aliyuncs"));
// BE
beLocation = locationPath.toStorageLocation().toString();
Assertions.assertTrue(beLocation.startsWith("oss://test.oss-dls.aliyuncs"));
Assertions.assertEquals(LocationPath.getFSIdentity(beLocation, null).first, FileSystemType.DFS);
Assertions.assertEquals(locationPath.getFileSystemType(), FileSystemType.DFS);

}

Expand Down
Loading