From 048882aff69fc05c7d5a14461d3bb0809482a557 Mon Sep 17 00:00:00 2001 From: yuzelin <33053040+yuzelin@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:42:14 +0800 Subject: [PATCH] [core] Refactor AbstractCatalog to make metastoreClientFactory public (#4472) --- .../apache/paimon/catalog/AbstractCatalog.java | 18 +++++------------- .../org/apache/paimon/hive/HiveCatalog.java | 7 +------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java b/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java index 8e885b95c160..c5cea0c215df 100644 --- a/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java +++ b/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java @@ -399,27 +399,19 @@ public Table getTable(Identifier identifier) throws TableNotExistException { protected Table getDataOrFormatTable(Identifier identifier) throws TableNotExistException { Preconditions.checkArgument(identifier.getSystemTableName() == null); + TableSchema tableSchema = getDataTableSchema(identifier); return FileStoreTableFactory.create( fileIO, getTableLocation(identifier), - getDataTableSchema(identifier), + tableSchema, new CatalogEnvironment( identifier, Lock.factory( lockFactory().orElse(null), lockContext().orElse(null), identifier), - metastoreClientFactory(identifier).orElse(null), + metastoreClientFactory(identifier, tableSchema).orElse(null), lineageMetaFactory)); } - protected CatalogEnvironment catalogEnvironment(Identifier identifier) - throws TableNotExistException { - return new CatalogEnvironment( - identifier, - Lock.factory(lockFactory().orElse(null), lockContext().orElse(null), identifier), - metastoreClientFactory(identifier).orElse(null), - lineageMetaFactory); - } - /** * Create a {@link FormatTable} identified by the given {@link Identifier}. * @@ -462,8 +454,8 @@ protected abstract TableSchema getDataTableSchema(Identifier identifier) throws TableNotExistException; /** Get metastore client factory for the table specified by {@code identifier}. */ - protected Optional metastoreClientFactory(Identifier identifier) - throws TableNotExistException { + public Optional metastoreClientFactory( + Identifier identifier, TableSchema schema) { return Optional.empty(); } diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java index 7c9bbde95f6c..a1950c374ab3 100644 --- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java +++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java @@ -191,12 +191,7 @@ public Optional lockContext() { } @Override - public Optional metastoreClientFactory(Identifier identifier) - throws TableNotExistException { - return metastoreClientFactory(identifier, getDataTableSchema(identifier)); - } - - private Optional metastoreClientFactory( + public Optional metastoreClientFactory( Identifier identifier, TableSchema schema) { Identifier tableIdentifier = new Identifier(identifier.getDatabaseName(), identifier.getTableName());