[fix](glue) support amazonaws.com.cn endpoint (#29128)

This commit is contained in:
Mingyu Chen
2023-12-29 13:50:30 +08:00
committed by GitHub
parent 9fc613de9c
commit f34b46a366
2 changed files with 16 additions and 10 deletions

View File

@ -550,7 +550,11 @@ public class PropertyConverter {
String region = S3Properties.getRegionOfEndpoint(endpoint);
if (!Strings.isNullOrEmpty(region)) {
props.put(S3Properties.REGION, region);
String s3Endpoint = "s3." + region + ".amazonaws.com";
String suffix = ".amazonaws.com";
if (endpoint.endsWith(".amazonaws.com.cn")) {
suffix = ".amazonaws.com.cn";
}
String s3Endpoint = "s3." + region + suffix;
if (isGlueIceberg) {
s3Endpoint = "https://" + s3Endpoint;
}

View File

@ -432,25 +432,27 @@ public class PropertyConverterTest extends TestWithFeService {
String catalogName = "hms_glue_old";
CreateCatalogStmt analyzedStmt = createStmt(queryOld);
HMSExternalCatalog catalog = createAndGetCatalog(analyzedStmt, catalogName);
Map<String, String> properties = catalog.getCatalogProperty().getProperties();
Map<String, String> properties = catalog.getProperties();
Assertions.assertEquals(properties.size(), 20);
Assertions.assertEquals("s3.us-east-1.amazonaws.com", properties.get(S3Properties.ENDPOINT));
Map<String, String> hdProps = catalog.getCatalogProperty().getHadoopProperties();
Assertions.assertEquals(hdProps.size(), 29);
String query = "create catalog hms_glue properties (\n"
+ " 'type'='hms',\n"
+ " 'hive.metastore.type'='glue',\n"
+ " 'hive.metastore.uris' = 'thrift://172.21.0.1:7004',\n"
+ " 'glue.endpoint' = 'glue.us-east-1.amazonaws.com',\n"
+ " 'glue.access_key' = 'akk',\n"
+ " 'glue.secret_key' = 'skk'\n"
+ ");";
+ " 'type'='hms',\n"
+ " 'hive.metastore.type'='glue',\n"
+ " 'hive.metastore.uris' = 'thrift://172.21.0.1:7004',\n"
+ " 'glue.endpoint' = 'glue.us-east-1.amazonaws.com.cn',\n"
+ " 'glue.access_key' = 'akk',\n"
+ " 'glue.secret_key' = 'skk'\n"
+ ");";
catalogName = "hms_glue";
CreateCatalogStmt analyzedStmtNew = createStmt(query);
HMSExternalCatalog catalogNew = createAndGetCatalog(analyzedStmtNew, catalogName);
Map<String, String> propertiesNew = catalogNew.getCatalogProperty().getProperties();
Map<String, String> propertiesNew = catalogNew.getProperties();
Assertions.assertEquals(propertiesNew.size(), 20);
Assertions.assertEquals("s3.us-east-1.amazonaws.com.cn", propertiesNew.get(S3Properties.ENDPOINT));
Map<String, String> hdPropsNew = catalogNew.getCatalogProperty().getHadoopProperties();
Assertions.assertEquals(hdPropsNew.size(), 29);