Skip to content

Commit

Permalink
[Fix] Add hive-conf-dir option to paimon catalog (apache#2187)
Browse files Browse the repository at this point in the history
  • Loading branch information
shidayang authored and ShawHee committed Dec 29, 2023
1 parent 460ec63 commit 65370a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
import com.netease.arctic.ams.api.CatalogMeta;
import com.netease.arctic.table.TableMetaStore;
import com.netease.arctic.utils.CatalogUtil;
import org.apache.paimon.hive.HiveCatalogOptions;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;

Expand All @@ -40,6 +44,11 @@ public class PaimonServerCatalog extends ExternalCatalog {
protected PaimonServerCatalog(CatalogMeta metadata) {
super(metadata);
this.tableMetaStore = CatalogUtil.buildMetaStore(metadata);
Optional<URL> hiveSiteLocation = tableMetaStore.getHiveSiteLocation();
hiveSiteLocation.ifPresent(
url ->
metadata.catalogProperties.put(
HiveCatalogOptions.HIVE_CONF_DIR.key(), new File(url.getPath()).getParent()));
this.paimonCatalog =
doAs(() -> new CommonUnifiedCatalog(null, metadata, metadata.catalogProperties));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
import org.apache.paimon.options.CatalogOptions;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -372,22 +371,6 @@ private CatalogMeta constructCatalogMeta(CatalogRegisterInfo info, CatalogMeta o
return catalogMeta;
}

private void checkPaimonCatalog(CatalogRegisterInfo info) {
if (!info.getTableFormatList().contains(TableFormat.PAIMON.name())) {
return;
}
Map<String, String> properties = info.getProperties();
if (!properties.containsKey(CatalogOptions.WAREHOUSE.key())) {
throw new IllegalArgumentException("Paimon catalog must have 'warehouse' property");
}

if (CATALOG_TYPE_HIVE.equalsIgnoreCase(info.getType())) {
if (!properties.containsKey(CatalogOptions.URI.key())) {
throw new IllegalArgumentException("Paimon hive catalog must have 'uri' property");
}
}
}

private void checkHiddenProperties(CatalogRegisterInfo info) {
getHiddenCatalogTableProperties().stream()
.filter(info.getTableProperties()::containsKey)
Expand Down Expand Up @@ -473,8 +456,6 @@ private void validateCatalogRegisterInfo(CatalogRegisterInfo info) {
String.format("Catalog type:%s require property:%s.", info.getType(), propertyName));
}
}

checkPaimonCatalog(info);
}

/** Get detail of some catalog. */
Expand Down

0 comments on commit 65370a9

Please sign in to comment.