[BugFix](MutilCatalog) fix local file system unavailable in iceberg hadoop catalog (#26769)

create catalog in local test/dev env like below:
create catalog iceberg PROPERTIES ('type'='iceberg','iceberg.catalog.type' = 'hadoop', 'warehouse' = '/export/workspace/warehouse');

we will get error: "Unrecognized 'warehouse' location format because name service is required."
This commit is contained in:
GoGoWen
2024-01-25 23:46:04 +08:00
committed by yiguolei
parent 6734fb10f9
commit 2ae02efd46

View File

@ -38,13 +38,16 @@ public class IcebergHadoopExternalCatalog extends IcebergExternalCatalog {
String warehouse = props.get(CatalogProperties.WAREHOUSE_LOCATION);
Preconditions.checkArgument(StringUtils.isNotEmpty(warehouse),
"Cannot initialize Iceberg HadoopCatalog because 'warehouse' must not be null or empty");
String nameService = StringUtils.substringBetween(warehouse, HdfsResource.HDFS_FILE_PREFIX, "/");
if (StringUtils.isEmpty(nameService)) {
throw new IllegalArgumentException("Unrecognized 'warehouse' location format"
+ " because name service is required.");
}
catalogProperty = new CatalogProperty(resource, props);
catalogProperty.addProperty(HdfsResource.HADOOP_FS_NAME, HdfsResource.HDFS_FILE_PREFIX + nameService);
if (StringUtils.startsWith(warehouse, HdfsResource.HDFS_PREFIX)) {
String nameService = StringUtils.substringBetween(warehouse, HdfsResource.HDFS_FILE_PREFIX, "/");
if (StringUtils.isEmpty(nameService)) {
throw new IllegalArgumentException("Unrecognized 'warehouse' location format"
+ " because name service is required.");
}
catalogProperty.addProperty(HdfsResource.HADOOP_FS_NAME, HdfsResource.HDFS_FILE_PREFIX + nameService);
}
}
@Override