Created transiently by {@link org.apache.doris.datasource.systable.PluginDrivenSysTable} during
* planning/describe (via {@code createSysExternalTable}); it is NEVER added to a persisted table map
* and is NOT GSON-registered, mirroring legacy sys ExternalTables (e.g.
- * {@link org.apache.doris.datasource.paimon.PaimonSysExternalTable}).
+ * {@code PaimonSysExternalTable}).
*
*
It reports {@link org.apache.doris.catalog.TableIf.TableType#PLUGIN_EXTERNAL_TABLE} (inherited);
* no connector-specific table type is introduced. The whole schema/partition/row-count path is reused
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/ExternalMetaCacheRouteResolver.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/ExternalMetaCacheRouteResolver.java
index 16576ea350005e..65d143ab7c5bb8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/ExternalMetaCacheRouteResolver.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/ExternalMetaCacheRouteResolver.java
@@ -22,7 +22,6 @@
import org.apache.doris.datasource.doris.RemoteDorisExternalCatalog;
import org.apache.doris.datasource.hive.HMSExternalCatalog;
import org.apache.doris.datasource.iceberg.IcebergExternalCatalog;
-import org.apache.doris.datasource.paimon.PaimonExternalCatalog;
import java.util.ArrayList;
import java.util.LinkedHashSet;
@@ -38,7 +37,6 @@ public class ExternalMetaCacheRouteResolver {
private static final String ENGINE_HIVE = "hive";
private static final String ENGINE_HUDI = "hudi";
private static final String ENGINE_ICEBERG = "iceberg";
- private static final String ENGINE_PAIMON = "paimon";
private static final String ENGINE_DORIS = "doris";
private final ExternalMetaCacheRegistry registry;
@@ -66,10 +64,6 @@ private void addBuiltinRoutes(Set resolved, CatalogIf> cata
resolved.add(registry.resolve(ENGINE_ICEBERG));
return;
}
- if (catalog instanceof PaimonExternalCatalog) {
- resolved.add(registry.resolve(ENGINE_PAIMON));
- return;
- }
if (catalog instanceof RemoteDorisExternalCatalog) {
resolved.add(registry.resolve(ENGINE_DORIS));
return;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonLatestSnapshotProjectionLoader.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonLatestSnapshotProjectionLoader.java
deleted file mode 100644
index 8e2c7a73b33901..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonLatestSnapshotProjectionLoader.java
+++ /dev/null
@@ -1,83 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.metacache.paimon;
-
-import org.apache.doris.catalog.Column;
-import org.apache.doris.datasource.CacheException;
-import org.apache.doris.datasource.NameMapping;
-import org.apache.doris.datasource.paimon.PaimonPartitionInfo;
-import org.apache.doris.datasource.paimon.PaimonSchemaCacheValue;
-import org.apache.doris.datasource.paimon.PaimonSnapshot;
-import org.apache.doris.datasource.paimon.PaimonSnapshotCacheValue;
-
-import org.apache.paimon.CoreOptions;
-import org.apache.paimon.Snapshot;
-import org.apache.paimon.schema.TableSchema;
-import org.apache.paimon.table.DataTable;
-import org.apache.paimon.table.Table;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * Resolves the latest snapshot runtime projection from the base table entry.
- */
-public final class PaimonLatestSnapshotProjectionLoader {
- @FunctionalInterface
- public interface SchemaValueLoader {
- PaimonSchemaCacheValue load(NameMapping nameMapping, long schemaId);
- }
-
- private final PaimonPartitionInfoLoader partitionInfoLoader;
- private final SchemaValueLoader schemaValueLoader;
-
- public PaimonLatestSnapshotProjectionLoader(PaimonPartitionInfoLoader partitionInfoLoader,
- SchemaValueLoader schemaValueLoader) {
- this.partitionInfoLoader = partitionInfoLoader;
- this.schemaValueLoader = schemaValueLoader;
- }
-
- public PaimonSnapshotCacheValue load(NameMapping nameMapping, Table paimonTable) {
- try {
- PaimonSnapshot latestSnapshot = resolveLatestSnapshot(paimonTable);
- List partitionColumns = schemaValueLoader.load(nameMapping, latestSnapshot.getSchemaId())
- .getPartitionColumns();
- PaimonPartitionInfo partitionInfo = partitionInfoLoader.load(nameMapping, paimonTable, partitionColumns);
- return new PaimonSnapshotCacheValue(partitionInfo, latestSnapshot);
- } catch (Exception e) {
- throw new CacheException("failed to load paimon snapshot %s.%s.%s: %s",
- e, nameMapping.getCtlId(), nameMapping.getLocalDbName(), nameMapping.getLocalTblName(),
- e.getMessage());
- }
- }
-
- private PaimonSnapshot resolveLatestSnapshot(Table paimonTable) {
- Table snapshotTable = paimonTable;
- long latestSnapshotId = PaimonSnapshot.INVALID_SNAPSHOT_ID;
- Optional optionalSnapshot = paimonTable.latestSnapshot();
- if (optionalSnapshot.isPresent()) {
- latestSnapshotId = optionalSnapshot.get().id();
- snapshotTable = paimonTable.copy(
- Collections.singletonMap(CoreOptions.SCAN_SNAPSHOT_ID.key(), String.valueOf(latestSnapshotId)));
- }
- DataTable dataTable = (DataTable) paimonTable;
- long latestSchemaId = dataTable.schemaManager().latest().map(TableSchema::id).orElse(0L);
- return new PaimonSnapshot(latestSnapshotId, latestSchemaId, snapshotTable);
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonPartitionInfoLoader.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonPartitionInfoLoader.java
deleted file mode 100644
index c29a359b9592d1..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonPartitionInfoLoader.java
+++ /dev/null
@@ -1,58 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.metacache.paimon;
-
-import org.apache.doris.catalog.Column;
-import org.apache.doris.common.AnalysisException;
-import org.apache.doris.datasource.CacheException;
-import org.apache.doris.datasource.NameMapping;
-import org.apache.doris.datasource.paimon.PaimonPartitionInfo;
-import org.apache.doris.datasource.paimon.PaimonUtil;
-
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.paimon.partition.Partition;
-import org.apache.paimon.table.Table;
-
-import java.util.List;
-
-/**
- * Loads partition info for a snapshot projection from the base Paimon table and catalog metadata.
- */
-public final class PaimonPartitionInfoLoader {
- private final PaimonTableLoader tableLoader;
-
- public PaimonPartitionInfoLoader(PaimonTableLoader tableLoader) {
- this.tableLoader = tableLoader;
- }
-
- public PaimonPartitionInfo load(NameMapping nameMapping, Table paimonTable, List partitionColumns)
- throws AnalysisException {
- if (CollectionUtils.isEmpty(partitionColumns)) {
- return PaimonPartitionInfo.EMPTY;
- }
- try {
- List paimonPartitions = tableLoader.catalog(nameMapping).getPaimonPartitions(nameMapping);
- boolean legacyPartitionName = PaimonUtil.isLegacyPartitionName(paimonTable);
- return PaimonUtil.generatePartitionInfo(partitionColumns, paimonPartitions, legacyPartitionName);
- } catch (Exception e) {
- throw new CacheException("failed to load paimon partition info %s.%s.%s: %s",
- e, nameMapping.getCtlId(), nameMapping.getLocalDbName(), nameMapping.getLocalTblName(),
- e.getMessage());
- }
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonTableLoader.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonTableLoader.java
deleted file mode 100644
index 0a134cfd7d7d32..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonTableLoader.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.metacache.paimon;
-
-import org.apache.doris.catalog.Env;
-import org.apache.doris.datasource.CacheException;
-import org.apache.doris.datasource.NameMapping;
-import org.apache.doris.datasource.paimon.PaimonExternalCatalog;
-
-import org.apache.paimon.table.Table;
-
-import java.io.IOException;
-
-/**
- * Loads the base Paimon table handle used by cache entries and runtime projections.
- */
-public final class PaimonTableLoader {
-
- public Table load(NameMapping nameMapping) {
- try {
- return catalog(nameMapping).getPaimonTable(nameMapping);
- } catch (Exception e) {
- throw new CacheException("failed to load paimon table %s.%s.%s: %s",
- e, nameMapping.getCtlId(), nameMapping.getLocalDbName(), nameMapping.getLocalTblName(),
- e.getMessage());
- }
- }
-
- public PaimonExternalCatalog catalog(NameMapping nameMapping) throws IOException {
- return (PaimonExternalCatalog) Env.getCurrentEnv().getCatalogMgr()
- .getCatalogOrException(nameMapping.getCtlId(), id -> new IOException("Catalog not found: " + id));
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/DorisToPaimonTypeVisitor.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/DorisToPaimonTypeVisitor.java
deleted file mode 100644
index aad8106563b4f4..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/DorisToPaimonTypeVisitor.java
+++ /dev/null
@@ -1,109 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.doris.catalog.ArrayType;
-import org.apache.doris.catalog.MapType;
-import org.apache.doris.catalog.PrimitiveType;
-import org.apache.doris.catalog.ScalarType;
-import org.apache.doris.catalog.StructField;
-import org.apache.doris.catalog.StructType;
-import org.apache.doris.catalog.Type;
-import org.apache.doris.datasource.DorisTypeVisitor;
-
-import org.apache.paimon.types.BigIntType;
-import org.apache.paimon.types.BooleanType;
-import org.apache.paimon.types.DataField;
-import org.apache.paimon.types.DataType;
-import org.apache.paimon.types.DateType;
-import org.apache.paimon.types.DecimalType;
-import org.apache.paimon.types.DoubleType;
-import org.apache.paimon.types.FloatType;
-import org.apache.paimon.types.IntType;
-import org.apache.paimon.types.RowType;
-import org.apache.paimon.types.TimestampType;
-import org.apache.paimon.types.VarBinaryType;
-import org.apache.paimon.types.VarCharType;
-import org.apache.paimon.types.VariantType;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class DorisToPaimonTypeVisitor extends DorisTypeVisitor {
-
- @Override
- public DataType struct(StructType struct, List fieldResults) {
- List fields = struct.getFields();
- List newFields = new ArrayList<>(fields.size());
- AtomicInteger atomicInteger = new AtomicInteger(-1);
- for (int i = 0; i < fields.size(); i++) {
- StructField field = fields.get(i);
- DataType fieldType = fieldResults.get(i).copy(field.getContainsNull());
- String comment = field.getComment();
- DataField dataField = new DataField(atomicInteger.incrementAndGet(), field.getName(), fieldType, comment);
- newFields.add(dataField);
- }
- return new RowType(newFields);
- }
-
- @Override
- public DataType field(StructField field, DataType typeResult) {
- return typeResult;
- }
-
- @Override
- public DataType array(ArrayType array, DataType elementResult) {
- return new org.apache.paimon.types.ArrayType(elementResult.copy(array.getContainsNull()));
- }
-
- @Override
- public DataType map(MapType map, DataType keyResult, DataType valueResult) {
- return new org.apache.paimon.types.MapType(keyResult.copy(false),
- valueResult.copy(map.getIsValueContainsNull()));
- }
-
- @Override
- public DataType atomic(Type atomic) {
- PrimitiveType primitiveType = atomic.getPrimitiveType();
- if (primitiveType.equals(PrimitiveType.BOOLEAN)) {
- return new BooleanType();
- } else if (primitiveType.equals(PrimitiveType.INT)) {
- return new IntType();
- } else if (primitiveType.equals(PrimitiveType.BIGINT)) {
- return new BigIntType();
- } else if (primitiveType.equals(PrimitiveType.FLOAT)) {
- return new FloatType();
- } else if (primitiveType.equals(PrimitiveType.DOUBLE)) {
- return new DoubleType();
- } else if (primitiveType.isCharFamily()) {
- return new VarCharType(VarCharType.MAX_LENGTH);
- } else if (primitiveType.equals(PrimitiveType.DATE) || primitiveType.equals(PrimitiveType.DATEV2)) {
- return new DateType();
- } else if (primitiveType.equals(PrimitiveType.DECIMALV2) || primitiveType.isDecimalV3Type()) {
- return new DecimalType(((ScalarType) atomic).getScalarPrecision(), ((ScalarType) atomic).getScalarScale());
- } else if (primitiveType.equals(PrimitiveType.DATETIME) || primitiveType.equals(PrimitiveType.DATETIMEV2)) {
- return new TimestampType();
- } else if (primitiveType.isVarbinaryType()) {
- return new VarBinaryType(VarBinaryType.MAX_LENGTH);
- } else if (primitiveType.isVariantType()) {
- return new VariantType();
- }
- throw new UnsupportedOperationException("Not a supported type: " + primitiveType);
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonDLFExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonDLFExternalCatalog.java
deleted file mode 100644
index a982abe5b017f8..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonDLFExternalCatalog.java
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import java.util.Map;
-
-@Deprecated
-public class PaimonDLFExternalCatalog extends PaimonExternalCatalog {
-
- public PaimonDLFExternalCatalog(long catalogId, String name, String resource,
- Map props, String comment) {
- super(catalogId, name, resource, props, comment);
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalCatalog.java
deleted file mode 100644
index 75e86769cd980a..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalCatalog.java
+++ /dev/null
@@ -1,192 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.doris.catalog.Env;
-import org.apache.doris.common.DdlException;
-import org.apache.doris.datasource.CatalogProperty;
-import org.apache.doris.datasource.ExternalCatalog;
-import org.apache.doris.datasource.InitCatalogLog;
-import org.apache.doris.datasource.NameMapping;
-import org.apache.doris.datasource.SessionContext;
-import org.apache.doris.datasource.metacache.CacheSpec;
-import org.apache.doris.datasource.property.metastore.AbstractPaimonProperties;
-
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.paimon.catalog.Catalog;
-import org.apache.paimon.catalog.Identifier;
-import org.apache.paimon.partition.Partition;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-// The subclasses of this class are all deprecated, only for meta persistence compatibility.
-public class PaimonExternalCatalog extends ExternalCatalog {
- private static final Logger LOG = LogManager.getLogger(PaimonExternalCatalog.class);
- public static final String PAIMON_CATALOG_TYPE = "paimon.catalog.type";
- public static final String PAIMON_FILESYSTEM = "filesystem";
- public static final String PAIMON_HMS = "hms";
- public static final String PAIMON_DLF = "dlf";
- public static final String PAIMON_REST = "rest";
- public static final String PAIMON_JDBC = "jdbc";
- public static final String PAIMON_TABLE_CACHE_ENABLE = "meta.cache.paimon.table.enable";
- public static final String PAIMON_TABLE_CACHE_TTL_SECOND = "meta.cache.paimon.table.ttl-second";
- public static final String PAIMON_TABLE_CACHE_CAPACITY = "meta.cache.paimon.table.capacity";
- protected String catalogType;
- protected Catalog catalog;
-
- private AbstractPaimonProperties paimonProperties;
-
- public PaimonExternalCatalog(long catalogId, String name, String resource, Map props,
- String comment) {
- super(catalogId, name, InitCatalogLog.Type.PAIMON, comment);
- catalogProperty = new CatalogProperty(resource, props);
- }
-
- @Override
- protected void initLocalObjectsImpl() {
- paimonProperties = (AbstractPaimonProperties) catalogProperty.getMetastoreProperties();
- catalogType = paimonProperties.getPaimonCatalogType();
- catalog = createCatalog();
- initPreExecutionAuthenticator();
- metadataOps = new PaimonMetadataOps(this, catalog);
- }
-
- @Override
- protected synchronized void initPreExecutionAuthenticator() {
- if (executionAuthenticator == null) {
- executionAuthenticator = paimonProperties.getExecutionAuthenticator();
- }
- }
-
- public String getCatalogType() {
- makeSureInitialized();
- return catalogType;
- }
-
- @Override
- public boolean tableExist(SessionContext ctx, String dbName, String tblName) {
- makeSureInitialized();
- return metadataOps.tableExist(dbName, tblName);
- }
-
- @Override
- protected List listTableNamesFromRemote(SessionContext ctx, String dbName) {
- return metadataOps.listTableNames(dbName);
- }
-
- public List getPaimonPartitions(NameMapping nameMapping) {
- makeSureInitialized();
- try {
- return executionAuthenticator.execute(() -> {
- List partitions = new ArrayList<>();
- try {
- partitions = catalog.listPartitions(Identifier.create(nameMapping.getRemoteDbName(),
- nameMapping.getRemoteTblName()));
- } catch (Catalog.TableNotExistException e) {
- LOG.warn("TableNotExistException", e);
- }
- return partitions;
- });
- } catch (Exception e) {
- throw new RuntimeException("Failed to get Paimon table partitions:" + getName() + "."
- + nameMapping.getRemoteDbName() + "." + nameMapping.getRemoteTblName() + ", because "
- + ExceptionUtils.getRootCauseMessage(e), e);
- }
- }
-
- public org.apache.paimon.table.Table getPaimonTable(NameMapping nameMapping) {
- return getPaimonTable(nameMapping, null, null);
- }
-
- public org.apache.paimon.table.Table getPaimonTable(NameMapping nameMapping, String branch,
- String queryType) {
- makeSureInitialized();
- try {
- Identifier identifier;
- if (branch != null && queryType != null) {
- identifier = new Identifier(nameMapping.getRemoteDbName(), nameMapping.getRemoteTblName(),
- branch, queryType);
- } else if (branch != null) {
- identifier = new Identifier(nameMapping.getRemoteDbName(), nameMapping.getRemoteTblName(),
- branch);
- } else if (queryType != null) {
- identifier = new Identifier(nameMapping.getRemoteDbName(), nameMapping.getRemoteTblName(),
- "main", queryType);
- } else {
- identifier = new Identifier(nameMapping.getRemoteDbName(), nameMapping.getRemoteTblName());
- }
- return executionAuthenticator.execute(() -> catalog.getTable(identifier));
- } catch (Exception e) {
- throw new RuntimeException("Failed to get Paimon table:" + getName() + "."
- + nameMapping.getRemoteDbName() + "." + nameMapping.getRemoteTblName() + "$" + queryType
- + ", because " + ExceptionUtils.getRootCauseMessage(e), e);
- }
- }
-
- protected Catalog createCatalog() {
- try {
- return paimonProperties.initializeCatalog(getName(), new ArrayList<>(catalogProperty
- .getOrderedStoragePropertiesList()));
- } catch (Exception e) {
- throw new RuntimeException("Failed to create catalog, catalog name: " + getName() + ", exception: "
- + ExceptionUtils.getRootCauseMessage(e), e);
- }
- }
-
- public Map getPaimonOptionsMap() {
- makeSureInitialized();
- return paimonProperties.getCatalogOptionsMap();
- }
-
- @Override
- public void checkProperties() throws DdlException {
- super.checkProperties();
- CacheSpec.checkBooleanProperty(catalogProperty.getOrDefault(PAIMON_TABLE_CACHE_ENABLE, null),
- PAIMON_TABLE_CACHE_ENABLE);
- CacheSpec.checkLongProperty(catalogProperty.getOrDefault(PAIMON_TABLE_CACHE_TTL_SECOND, null),
- -1L, PAIMON_TABLE_CACHE_TTL_SECOND);
- CacheSpec.checkLongProperty(catalogProperty.getOrDefault(PAIMON_TABLE_CACHE_CAPACITY, null),
- 0L, PAIMON_TABLE_CACHE_CAPACITY);
- catalogProperty.checkMetaStoreAndStorageProperties(AbstractPaimonProperties.class);
- }
-
- @Override
- public void notifyPropertiesUpdated(Map updatedProps) {
- super.notifyPropertiesUpdated(updatedProps);
- if (updatedProps.keySet().stream()
- .anyMatch(key -> CacheSpec.isMetaCacheKeyForEngine(key, PaimonExternalMetaCache.ENGINE))) {
- Env.getCurrentEnv().getExtMetaCacheMgr().removeCatalogByEngine(getId(), PaimonExternalMetaCache.ENGINE);
- }
- }
-
- @Override
- public void onClose() {
- super.onClose();
- if (null != catalog) {
- try {
- catalog.close();
- } catch (Exception e) {
- LOG.warn("Failed to close paimon catalog: {}", getName(), e);
- }
- }
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalCatalogFactory.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalCatalogFactory.java
deleted file mode 100644
index affe4995f107c2..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalCatalogFactory.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.doris.common.DdlException;
-import org.apache.doris.datasource.ExternalCatalog;
-
-import org.apache.commons.lang3.StringUtils;
-
-import java.util.Map;
-
-public class PaimonExternalCatalogFactory {
-
- public static ExternalCatalog createCatalog(long catalogId, String name, String resource, Map props,
- String comment) throws DdlException {
- String metastoreType = props.get(PaimonExternalCatalog.PAIMON_CATALOG_TYPE);
- if (StringUtils.isEmpty(metastoreType)) {
- metastoreType = PaimonExternalCatalog.PAIMON_FILESYSTEM;
- }
- metastoreType = metastoreType.toLowerCase();
- switch (metastoreType) {
- case PaimonExternalCatalog.PAIMON_HMS:
- case PaimonExternalCatalog.PAIMON_FILESYSTEM:
- case PaimonExternalCatalog.PAIMON_DLF:
- case PaimonExternalCatalog.PAIMON_REST:
- case PaimonExternalCatalog.PAIMON_JDBC:
- return new PaimonExternalCatalog(catalogId, name, resource, props, comment);
- default:
- throw new DdlException("Unknown " + PaimonExternalCatalog.PAIMON_CATALOG_TYPE
- + " value: " + metastoreType);
- }
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalDatabase.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalDatabase.java
deleted file mode 100644
index fdbad45c5d0af9..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalDatabase.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.doris.datasource.ExternalCatalog;
-import org.apache.doris.datasource.ExternalDatabase;
-import org.apache.doris.datasource.InitDatabaseLog;
-
-public class PaimonExternalDatabase extends ExternalDatabase {
-
- public PaimonExternalDatabase(ExternalCatalog extCatalog, Long id, String name, String remoteName) {
- super(extCatalog, id, name, remoteName, InitDatabaseLog.Type.PAIMON);
- }
-
- @Override
- public PaimonExternalTable buildTableInternal(String remoteTableName, String localTableName, long tblId,
- ExternalCatalog catalog,
- ExternalDatabase db) {
- return new PaimonExternalTable(tblId, localTableName, remoteTableName, (PaimonExternalCatalog) extCatalog,
- (PaimonExternalDatabase) db);
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalMetaCache.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalMetaCache.java
deleted file mode 100644
index 1d08ba1274e256..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalMetaCache.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.doris.datasource.CacheException;
-import org.apache.doris.datasource.ExternalCatalog;
-import org.apache.doris.datasource.ExternalTable;
-import org.apache.doris.datasource.NameMapping;
-import org.apache.doris.datasource.SchemaCacheValue;
-import org.apache.doris.datasource.metacache.AbstractExternalMetaCache;
-import org.apache.doris.datasource.metacache.MetaCacheEntryDef;
-import org.apache.doris.datasource.metacache.MetaCacheEntryInvalidation;
-import org.apache.doris.datasource.metacache.paimon.PaimonLatestSnapshotProjectionLoader;
-import org.apache.doris.datasource.metacache.paimon.PaimonPartitionInfoLoader;
-import org.apache.doris.datasource.metacache.paimon.PaimonTableLoader;
-
-import org.apache.paimon.table.Table;
-
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-
-/**
- * Paimon engine implementation of {@link AbstractExternalMetaCache}.
- *
- *
Registered entries:
- *
- *
{@code table}: loaded Paimon table handle per table mapping
- *
{@code schema}: schema cache keyed by table identity + schema id
- *
- *
- *
Latest snapshot metadata is modeled as a runtime projection memoized inside the table cache
- * value instead of as an independent cache entry.
- *
- *
Invalidation behavior:
- *
- *
db/table invalidation clears table and schema entries by matching local names
- *
partition-level invalidation falls back to table-level invalidation
- *
- */
-public class PaimonExternalMetaCache extends AbstractExternalMetaCache {
- public static final String ENGINE = "paimon";
- public static final String ENTRY_TABLE = "table";
- public static final String ENTRY_SCHEMA = "schema";
-
- private final EntryHandle tableEntry;
- private final EntryHandle schemaEntry;
- private final PaimonTableLoader tableLoader;
- private final PaimonLatestSnapshotProjectionLoader latestSnapshotProjectionLoader;
-
- public PaimonExternalMetaCache(ExecutorService refreshExecutor) {
- super(ENGINE, refreshExecutor);
- tableLoader = new PaimonTableLoader();
- latestSnapshotProjectionLoader = new PaimonLatestSnapshotProjectionLoader(
- new PaimonPartitionInfoLoader(tableLoader), this::getPaimonSchemaCacheValue);
- tableEntry = registerEntry(MetaCacheEntryDef.of(ENTRY_TABLE, NameMapping.class, PaimonTableCacheValue.class,
- this::loadTableCacheValue, defaultEntryCacheSpec(),
- MetaCacheEntryInvalidation.forNameMapping(nameMapping -> nameMapping)));
- schemaEntry = registerEntry(MetaCacheEntryDef.of(ENTRY_SCHEMA, PaimonSchemaCacheKey.class,
- SchemaCacheValue.class, this::loadSchemaCacheValue, defaultSchemaCacheSpec(),
- MetaCacheEntryInvalidation.forNameMapping(PaimonSchemaCacheKey::getNameMapping)));
- }
-
- public Table getPaimonTable(ExternalTable dorisTable) {
- NameMapping nameMapping = dorisTable.getOrBuildNameMapping();
- return tableEntry.get(nameMapping.getCtlId()).get(nameMapping).getPaimonTable();
- }
-
- public Table getPaimonTable(NameMapping nameMapping) {
- return tableEntry.get(nameMapping.getCtlId()).get(nameMapping).getPaimonTable();
- }
-
- public PaimonSnapshotCacheValue getSnapshotCache(ExternalTable dorisTable) {
- NameMapping nameMapping = dorisTable.getOrBuildNameMapping();
- return tableEntry.get(nameMapping.getCtlId()).get(nameMapping).getLatestSnapshotCacheValue();
- }
-
- public PaimonSchemaCacheValue getPaimonSchemaCacheValue(NameMapping nameMapping, long schemaId) {
- SchemaCacheValue schemaCacheValue = schemaEntry.get(nameMapping.getCtlId())
- .get(new PaimonSchemaCacheKey(nameMapping, schemaId));
- return (PaimonSchemaCacheValue) schemaCacheValue;
- }
-
- private PaimonTableCacheValue loadTableCacheValue(NameMapping nameMapping) {
- Table paimonTable = tableLoader.load(nameMapping);
- return new PaimonTableCacheValue(paimonTable,
- () -> latestSnapshotProjectionLoader.load(nameMapping, paimonTable));
- }
-
- private SchemaCacheValue loadSchemaCacheValue(PaimonSchemaCacheKey key) {
- ExternalTable dorisTable = findExternalTable(key.getNameMapping(), ENGINE);
- return dorisTable.initSchemaAndUpdateTime(key).orElseThrow(() ->
- new CacheException("failed to load paimon schema cache value for: %s.%s.%s, schemaId: %s",
- null, key.getNameMapping().getCtlId(), key.getNameMapping().getLocalDbName(),
- key.getNameMapping().getLocalTblName(), key.getSchemaId()));
- }
-
- @Override
- protected Map catalogPropertyCompatibilityMap() {
- return singleCompatibilityMap(ExternalCatalog.SCHEMA_CACHE_TTL_SECOND, ENTRY_SCHEMA);
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalTable.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalTable.java
deleted file mode 100644
index 1775a984f2cd5f..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalTable.java
+++ /dev/null
@@ -1,429 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.doris.analysis.TableScanParams;
-import org.apache.doris.analysis.TableSnapshot;
-import org.apache.doris.catalog.Column;
-import org.apache.doris.catalog.MTMV;
-import org.apache.doris.catalog.PartitionItem;
-import org.apache.doris.catalog.PartitionType;
-import org.apache.doris.common.AnalysisException;
-import org.apache.doris.common.DdlException;
-import org.apache.doris.datasource.CacheException;
-import org.apache.doris.datasource.ExternalTable;
-import org.apache.doris.datasource.SchemaCacheKey;
-import org.apache.doris.datasource.SchemaCacheValue;
-import org.apache.doris.datasource.mvcc.MvccSnapshot;
-import org.apache.doris.datasource.mvcc.MvccTable;
-import org.apache.doris.datasource.mvcc.MvccUtil;
-import org.apache.doris.datasource.systable.PaimonSysTable;
-import org.apache.doris.datasource.systable.SysTable;
-import org.apache.doris.mtmv.MTMVBaseTableIf;
-import org.apache.doris.mtmv.MTMVRefreshContext;
-import org.apache.doris.mtmv.MTMVRelatedTableIf;
-import org.apache.doris.mtmv.MTMVSnapshotIdSnapshot;
-import org.apache.doris.mtmv.MTMVSnapshotIf;
-import org.apache.doris.mtmv.MTMVTimestampSnapshot;
-import org.apache.doris.statistics.AnalysisInfo;
-import org.apache.doris.statistics.BaseAnalysisTask;
-import org.apache.doris.statistics.ExternalAnalysisTask;
-import org.apache.doris.thrift.THiveTable;
-import org.apache.doris.thrift.TTableDescriptor;
-import org.apache.doris.thrift.TTableType;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.paimon.CoreOptions;
-import org.apache.paimon.Snapshot;
-import org.apache.paimon.partition.Partition;
-import org.apache.paimon.schema.TableSchema;
-import org.apache.paimon.table.DataTable;
-import org.apache.paimon.table.Table;
-import org.apache.paimon.table.source.Split;
-import org.apache.paimon.types.DataField;
-import org.apache.paimon.types.DataTypeRoot;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-public class PaimonExternalTable extends ExternalTable implements MTMVRelatedTableIf, MTMVBaseTableIf, MvccTable {
-
- private static final Logger LOG = LogManager.getLogger(PaimonExternalTable.class);
-
- public PaimonExternalTable(long id, String name, String remoteName, PaimonExternalCatalog catalog,
- PaimonExternalDatabase db) {
- super(id, name, remoteName, catalog, db, TableType.PAIMON_EXTERNAL_TABLE);
- }
-
- @Override
- public String getMetaCacheEngine() {
- return PaimonExternalMetaCache.ENGINE;
- }
-
- public String getPaimonCatalogType() {
- return ((PaimonExternalCatalog) catalog).getCatalogType();
- }
-
- protected synchronized void makeSureInitialized() {
- super.makeSureInitialized();
- if (!objectCreated) {
- objectCreated = true;
- }
- }
-
- public Table getPaimonTable(Optional snapshot) {
- if (snapshot.isPresent()) {
- // MTMV scenario: get from snapshot cache
- return getOrFetchSnapshotCacheValue(snapshot).getSnapshot().getTable();
- } else {
- // Normal query scenario: get directly from table cache
- return PaimonUtils.getPaimonTable(this);
- }
- }
-
- private PaimonSnapshotCacheValue getPaimonSnapshotCacheValue(Optional tableSnapshot,
- Optional scanParams) {
- makeSureInitialized();
-
- // Current limitation: cannot specify both table snapshot and scan parameters simultaneously.
- if (tableSnapshot.isPresent() || (scanParams.isPresent() && scanParams.get().isTag())) {
- // If a snapshot is specified,
- // use the specified snapshot and the corresponding schema(not the latest
- // schema).
- try {
- Table baseTable = getBasePaimonTable();
- DataTable dataTable = (DataTable) baseTable;
- Snapshot snapshot;
- Map scanOptions = new HashMap<>();
-
- if (tableSnapshot.isPresent()) {
- TableSnapshot snapshotOpt = tableSnapshot.get();
- String value = snapshotOpt.getValue();
- if (snapshotOpt.getType() == TableSnapshot.VersionType.TIME) {
- snapshot = PaimonUtil.getPaimonSnapshotByTimestamp(
- dataTable, value, PaimonUtil.isDigitalString(value));
- scanOptions.put(CoreOptions.SCAN_SNAPSHOT_ID.key(), String.valueOf(snapshot.id()));
- } else {
- if (PaimonUtil.isDigitalString(value)) {
- snapshot = PaimonUtil.getPaimonSnapshotBySnapshotId(dataTable, value);
- scanOptions.put(CoreOptions.SCAN_SNAPSHOT_ID.key(), String.valueOf(snapshot.id()));
- } else {
- snapshot = PaimonUtil.getPaimonSnapshotByTag(dataTable, value);
- scanOptions.put(CoreOptions.SCAN_TAG_NAME.key(), value);
- }
- }
- } else {
- String tagName = PaimonUtil.extractBranchOrTagName(scanParams.get());
- snapshot = PaimonUtil.getPaimonSnapshotByTag(dataTable, tagName);
- scanOptions.put(CoreOptions.SCAN_TAG_NAME.key(), tagName);
- }
-
- Table scanTable = baseTable.copy(scanOptions);
- return new PaimonSnapshotCacheValue(PaimonPartitionInfo.EMPTY,
- new PaimonSnapshot(snapshot.id(), snapshot.schemaId(), scanTable));
- } catch (Exception e) {
- LOG.warn("Failed to get Paimon snapshot for table {}", getOrBuildNameMapping().getFullLocalName(), e);
- throw new RuntimeException(
- "Failed to get Paimon snapshot: " + (e.getMessage() == null ? "unknown cause" : e.getMessage()),
- e);
- }
- } else if (scanParams.isPresent() && scanParams.get().isBranch()) {
- try {
- Table baseTable = getBasePaimonTable();
- String branch = PaimonUtil.resolvePaimonBranch(scanParams.get(), baseTable);
- Table table = ((PaimonExternalCatalog) catalog).getPaimonTable(getOrBuildNameMapping(), branch, null);
- Optional latestSnapshot = table.latestSnapshot();
- long latestSnapshotId = PaimonSnapshot.INVALID_SNAPSHOT_ID;
- if (latestSnapshot.isPresent()) {
- latestSnapshotId = latestSnapshot.get().id();
- }
- // Branches in Paimon can have independent schemas and snapshots.
- // TODO: Add time travel support for paimon branch tables.
- DataTable dataTable = (DataTable) table;
- Long schemaId = dataTable.schemaManager().latest().map(TableSchema::id).orElse(0L);
- return new PaimonSnapshotCacheValue(PaimonPartitionInfo.EMPTY,
- new PaimonSnapshot(latestSnapshotId, schemaId, dataTable));
- } catch (Exception e) {
- LOG.warn("Failed to get Paimon branch for table {}", getOrBuildNameMapping().getFullLocalName(), e);
- throw new RuntimeException(
- "Failed to get Paimon branch: " + (e.getMessage() == null ? "unknown cause" : e.getMessage()),
- e);
- }
- } else {
- // Otherwise, use the latest snapshot and the latest schema.
- return PaimonUtils.getLatestSnapshotCacheValue(this);
- }
- }
-
- @Override
- public TTableDescriptor toThrift() {
- List schema = getFullSchema();
- if (PaimonExternalCatalog.PAIMON_HMS.equals(getPaimonCatalogType())
- || PaimonExternalCatalog.PAIMON_FILESYSTEM.equals(getPaimonCatalogType())
- || PaimonExternalCatalog.PAIMON_DLF.equals(getPaimonCatalogType())
- || PaimonExternalCatalog.PAIMON_REST.equals(getPaimonCatalogType())
- || PaimonExternalCatalog.PAIMON_JDBC.equals(getPaimonCatalogType())) {
- THiveTable tHiveTable = new THiveTable(dbName, name, new HashMap<>());
- TTableDescriptor tTableDescriptor = new TTableDescriptor(getId(), TTableType.HIVE_TABLE, schema.size(), 0,
- getName(), dbName);
- tTableDescriptor.setHiveTable(tHiveTable);
- return tTableDescriptor;
- } else {
- throw new IllegalArgumentException(
- "Currently only supports hms/dlf/rest/filesystem/jdbc catalog, do not support: "
- + getPaimonCatalogType());
- }
- }
-
- @Override
- public BaseAnalysisTask createAnalysisTask(AnalysisInfo info) {
- makeSureInitialized();
- return new ExternalAnalysisTask(info);
- }
-
- @Override
- public long fetchRowCount() {
- makeSureInitialized();
- long rowCount = 0;
- List splits = getBasePaimonTable().newReadBuilder().newScan().plan().splits();
- for (Split split : splits) {
- rowCount += split.rowCount();
- }
- if (rowCount == 0) {
- LOG.info("Paimon table {} row count is 0, return -1", name);
- }
- return rowCount > 0 ? rowCount : UNKNOWN_ROW_COUNT;
- }
-
- @Override
- public void beforeMTMVRefresh(MTMV mtmv) throws DdlException {
- }
-
- @Override
- public Map getAndCopyPartitionItems(Optional snapshot) {
- return Maps.newHashMap(getNameToPartitionItems(snapshot));
- }
-
- @Override
- public PartitionType getPartitionType(Optional snapshot) {
- if (isPartitionInvalid(snapshot)) {
- return PartitionType.UNPARTITIONED;
- }
- return getPartitionColumns(snapshot).size() > 0 ? PartitionType.LIST : PartitionType.UNPARTITIONED;
- }
-
- @Override
- public Set getPartitionColumnNames(Optional snapshot) {
- return getPartitionColumns(snapshot).stream()
- .map(c -> c.getName().toLowerCase()).collect(Collectors.toSet());
- }
-
- @Override
- public List getPartitionColumns(Optional snapshot) {
- if (isPartitionInvalid(snapshot)) {
- return Collections.emptyList();
- }
- return getPaimonSchemaCacheValue(snapshot).getPartitionColumns();
- }
-
- public boolean isPartitionInvalid(Optional snapshot) {
- PaimonSnapshotCacheValue paimonSnapshotCacheValue = getOrFetchSnapshotCacheValue(snapshot);
- return paimonSnapshotCacheValue.getPartitionInfo().isPartitionInvalid();
- }
-
- @Override
- public MTMVSnapshotIf getPartitionSnapshot(String partitionName, MTMVRefreshContext context,
- Optional snapshot)
- throws AnalysisException {
- Partition paimonPartition = getOrFetchSnapshotCacheValue(snapshot).getPartitionInfo().getNameToPartition()
- .get(partitionName);
- if (paimonPartition == null) {
- throw new AnalysisException("can not find partition: " + partitionName);
- }
- return new MTMVTimestampSnapshot(paimonPartition.lastFileCreationTime());
- }
-
- @Override
- public MTMVSnapshotIf getTableSnapshot(MTMVRefreshContext context, Optional snapshot)
- throws AnalysisException {
- return getTableSnapshot(snapshot);
- }
-
- public Map getPartitionSnapshot(
- Optional snapshot) {
-
- return getOrFetchSnapshotCacheValue(snapshot).getPartitionInfo()
- .getNameToPartition();
- }
-
- @Override
- public MTMVSnapshotIf getTableSnapshot(Optional snapshot) throws AnalysisException {
- PaimonSnapshotCacheValue paimonSnapshot = getOrFetchSnapshotCacheValue(snapshot);
- return new MTMVSnapshotIdSnapshot(paimonSnapshot.getSnapshot().getSnapshotId());
- }
-
- @Override
- public long getNewestUpdateVersionOrTime() {
- return getPaimonSnapshotCacheValue(Optional.empty(), Optional.empty()).getPartitionInfo().getNameToPartition()
- .values().stream()
- .mapToLong(Partition::lastFileCreationTime).max().orElse(0);
- }
-
- @Override
- public boolean isPartitionColumnAllowNull() {
- // Paimon will write to the 'null' partition regardless of whether it is' null or 'null'.
- // The logic is inconsistent with Doris' empty partition logic, so it needs to return false.
- // However, when Spark creates Paimon tables, specifying 'not null' does not take effect.
- // In order to successfully create the materialized view, false is returned here.
- // The cost is that Paimon partition writes a null value, and the materialized view cannot detect this data.
- return true;
- }
-
- @Override
- public MvccSnapshot loadSnapshot(Optional tableSnapshot, Optional scanParams) {
- return new PaimonMvccSnapshot(getPaimonSnapshotCacheValue(tableSnapshot, scanParams));
- }
-
- @Override
- public Map getNameToPartitionItems(Optional snapshot) {
- return getOrFetchSnapshotCacheValue(snapshot).getPartitionInfo().getNameToPartitionItem();
- }
-
- @Override
- public boolean supportInternalPartitionPruned() {
- return true;
- }
-
- @Override
- public boolean supportsExternalMetadataPreload() {
- return true;
- }
-
- @Override
- public boolean supportsLatestSnapshotPreload() {
- return true;
- }
-
- @Override
- public List getFullSchema() {
- return getPaimonSchemaCacheValue(MvccUtil.getSnapshotFromContext(this)).getSchema();
- }
-
- @Override
- public Optional initSchema(SchemaCacheKey key) {
- makeSureInitialized();
- PaimonSchemaCacheKey paimonSchemaCacheKey = (PaimonSchemaCacheKey) key;
- try {
- Table table = getBasePaimonTable();
- TableSchema tableSchema = ((DataTable) table).schemaManager().schema(paimonSchemaCacheKey.getSchemaId());
- List columns = tableSchema.fields();
- List dorisColumns = Lists.newArrayListWithCapacity(columns.size());
- Set partitionColumnNames = Sets.newHashSet(tableSchema.partitionKeys());
- List partitionColumns = Lists.newArrayList();
- for (DataField field : columns) {
- Column column = new Column(field.name().toLowerCase(),
- PaimonUtil.paimonTypeToDorisType(field.type(), getCatalog().getEnableMappingVarbinary(),
- getCatalog().getEnableMappingTimestampTz()),
- true,
- null, true, field.description(), true,
- -1);
- PaimonUtil.updatePaimonColumnUniqueId(column, field);
- if (field.type().getTypeRoot() == DataTypeRoot.TIMESTAMP_WITH_LOCAL_TIME_ZONE) {
- column.setWithTZExtraInfo();
- }
- dorisColumns.add(column);
- if (partitionColumnNames.contains(field.name())) {
- partitionColumns.add(column);
- }
- }
- return Optional.of(new PaimonSchemaCacheValue(dorisColumns, partitionColumns, tableSchema));
- } catch (Exception e) {
- throw new CacheException("failed to initSchema for: %s.%s.%s.%s",
- null, getCatalog().getName(), key.getNameMapping().getLocalDbName(),
- key.getNameMapping().getLocalTblName(),
- paimonSchemaCacheKey.getSchemaId());
- }
- }
-
- @Override
- public Optional getSchemaCacheValue() {
- return Optional.of(getPaimonSchemaCacheValue(MvccUtil.getSnapshotFromContext(this)));
- }
-
- private PaimonSchemaCacheValue getPaimonSchemaCacheValue(Optional snapshot) {
- PaimonSnapshotCacheValue snapshotCacheValue = getOrFetchSnapshotCacheValue(snapshot);
- return PaimonUtils.getSchemaCacheValue(this, snapshotCacheValue);
- }
-
- private PaimonSnapshotCacheValue getOrFetchSnapshotCacheValue(Optional snapshot) {
- if (snapshot.isPresent()) {
- return ((PaimonMvccSnapshot) snapshot.get()).getSnapshotCacheValue();
- } else {
- // Use new lazy-loading snapshot cache API
- return PaimonUtils.getSnapshotCacheValue(snapshot, this);
- }
- }
-
- @Override
- public Map getSupportedSysTables() {
- makeSureInitialized();
- return PaimonSysTable.SUPPORTED_SYS_TABLES;
- }
-
- @Override
- public String getComment() {
- Table table = getBasePaimonTable();
- return table.comment().isPresent() ? table.comment().get() : "";
- }
-
- public Map getTableProperties() {
- Table table = getBasePaimonTable();
- if (table instanceof DataTable) {
- DataTable dataTable = (DataTable) table;
- Map properties = new LinkedHashMap<>(dataTable.coreOptions().toMap());
-
- if (!dataTable.primaryKeys().isEmpty()) {
- properties.put(CoreOptions.PRIMARY_KEY.key(), String.join(",", dataTable.primaryKeys()));
- }
-
- return properties;
- } else {
- return Collections.emptyMap();
- }
- }
-
- @Override
- public boolean isPartitionedTable() {
- makeSureInitialized();
- return !getBasePaimonTable().partitionKeys().isEmpty();
- }
-
- private Table getBasePaimonTable() {
- return PaimonUtils.getPaimonTable(this);
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonFileExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonFileExternalCatalog.java
deleted file mode 100644
index 9bc233f4b05f15..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonFileExternalCatalog.java
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import java.util.Map;
-
-@Deprecated
-public class PaimonFileExternalCatalog extends PaimonExternalCatalog {
-
- public PaimonFileExternalCatalog(long catalogId, String name, String resource,
- Map props, String comment) {
- super(catalogId, name, resource, props, comment);
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonHMSExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonHMSExternalCatalog.java
deleted file mode 100644
index 0a4702ab4f1cd1..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonHMSExternalCatalog.java
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import java.util.Map;
-
-@Deprecated
-public class PaimonHMSExternalCatalog extends PaimonExternalCatalog {
-
- public PaimonHMSExternalCatalog(long catalogId, String name, String resource,
- Map props, String comment) {
- super(catalogId, name, resource, props, comment);
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonMetadataOps.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonMetadataOps.java
deleted file mode 100644
index b8263250c3dafd..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonMetadataOps.java
+++ /dev/null
@@ -1,405 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.doris.analysis.PartitionDesc;
-import org.apache.doris.catalog.StructField;
-import org.apache.doris.catalog.StructType;
-import org.apache.doris.catalog.Type;
-import org.apache.doris.catalog.info.CreateOrReplaceBranchInfo;
-import org.apache.doris.catalog.info.CreateOrReplaceTagInfo;
-import org.apache.doris.catalog.info.DropBranchInfo;
-import org.apache.doris.catalog.info.DropTagInfo;
-import org.apache.doris.common.DdlException;
-import org.apache.doris.common.ErrorCode;
-import org.apache.doris.common.ErrorReport;
-import org.apache.doris.common.UserException;
-import org.apache.doris.common.security.authentication.ExecutionAuthenticator;
-import org.apache.doris.common.util.Util;
-import org.apache.doris.datasource.DorisTypeVisitor;
-import org.apache.doris.datasource.ExternalCatalog;
-import org.apache.doris.datasource.ExternalDatabase;
-import org.apache.doris.datasource.ExternalTable;
-import org.apache.doris.datasource.operations.ExternalMetadataOps;
-import org.apache.doris.nereids.trees.plans.commands.info.ColumnDefinition;
-import org.apache.doris.nereids.trees.plans.commands.info.CreateTableInfo;
-
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.paimon.CoreOptions;
-import org.apache.paimon.catalog.Catalog;
-import org.apache.paimon.catalog.Catalog.DatabaseNotEmptyException;
-import org.apache.paimon.catalog.Catalog.DatabaseNotExistException;
-import org.apache.paimon.catalog.Catalog.TableAlreadyExistException;
-import org.apache.paimon.catalog.Catalog.TableNotExistException;
-import org.apache.paimon.catalog.Identifier;
-import org.apache.paimon.schema.Schema;
-import org.apache.paimon.types.DataType;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-public class PaimonMetadataOps implements ExternalMetadataOps {
-
- private static final Logger LOG = LogManager.getLogger(PaimonMetadataOps.class);
- protected Catalog catalog;
- protected ExternalCatalog dorisCatalog;
- private ExecutionAuthenticator executionAuthenticator;
- private static final String PRIMARY_KEY_IDENTIFIER = "primary-key";
- private static final String PROP_COMMENT = "comment";
- private static final String PROP_LOCATION = "location";
-
- public PaimonMetadataOps(ExternalCatalog dorisCatalog, Catalog catalog) {
- this.dorisCatalog = dorisCatalog;
- this.catalog = catalog;
- this.executionAuthenticator = dorisCatalog.getExecutionAuthenticator();
- }
-
-
- @Override
- public boolean createDbImpl(String dbName, boolean ifNotExists, Map properties)
- throws DdlException {
- try {
- return executionAuthenticator.execute(() -> performCreateDb(dbName, ifNotExists, properties));
- } catch (Exception e) {
- throw new DdlException("Failed to create database: "
- + dbName + ": " + Util.getRootCauseMessage(e), e);
- }
- }
-
- private boolean performCreateDb(String dbName, boolean ifNotExists, Map properties)
- throws DdlException, Catalog.DatabaseAlreadyExistException {
- if (databaseExist(dbName)) {
- if (ifNotExists) {
- LOG.info("create database[{}] which already exists", dbName);
- return true;
- } else {
- ErrorReport.reportDdlException(ErrorCode.ERR_DB_CREATE_EXISTS, dbName);
- }
- }
-
- if (!properties.isEmpty() && dorisCatalog instanceof PaimonExternalCatalog) {
- String catalogType = ((PaimonExternalCatalog) dorisCatalog).getCatalogType();
- if (!PaimonExternalCatalog.PAIMON_HMS.equals(catalogType)) {
- throw new DdlException(
- "Not supported: create database with properties for paimon catalog type: " + catalogType);
- }
- }
-
- catalog.createDatabase(dbName, ifNotExists, properties);
- return false;
- }
-
- @Override
- public void afterCreateDb() {
- dorisCatalog.resetMetaCacheNames();
- }
-
- @Override
- public void dropDbImpl(String dbName, boolean ifExists, boolean force) throws DdlException {
- try {
- executionAuthenticator.execute(() -> {
- performDropDb(dbName, ifExists, force);
- return null;
- });
- } catch (Exception e) {
- throw new DdlException(
- "Failed to drop database: " + dbName + ", error message is:" + e.getMessage(), e);
- }
- }
-
- private void performDropDb(String dbName, boolean ifExists, boolean force) throws DdlException {
- ExternalDatabase dorisDb = dorisCatalog.getDbNullable(dbName);
- if (dorisDb == null) {
- if (ifExists) {
- LOG.info("drop database[{}] which does not exist", dbName);
- // Database does not exist and IF EXISTS is specified; treat as no-op.
- return;
- } else {
- ErrorReport.reportDdlException(ErrorCode.ERR_DB_DROP_EXISTS, dbName);
- // ErrorReport.reportDdlException is expected to throw DdlException.
- return;
- }
- }
-
- if (force) {
- List tableNames = listTableNames(dbName);
- if (!tableNames.isEmpty()) {
- LOG.info("drop database[{}] with force, drop all tables, num: {}", dbName, tableNames.size());
- }
- for (String tableName : tableNames) {
- performDropTable(dbName, tableName, true);
- }
- }
-
- try {
- catalog.dropDatabase(dbName, ifExists, force);
- } catch (DatabaseNotExistException e) {
- throw new RuntimeException("database " + dbName + " does not exist!");
- } catch (DatabaseNotEmptyException e) {
- throw new RuntimeException("database " + dbName + " is not empty! please check!");
- }
- }
-
- @Override
- public void afterDropDb(String dbName) {
- dorisCatalog.unregisterDatabase(dbName);
- }
-
- @Override
- public boolean createTableImpl(CreateTableInfo createTableInfo) throws UserException {
- try {
- return executionAuthenticator.execute(() -> performCreateTable(createTableInfo));
- } catch (Exception e) {
- throw new DdlException(
- "Failed to create table: " + createTableInfo.getTableName() + ", error message is:" + e.getMessage(),
- e);
- }
- }
-
- public boolean performCreateTable(CreateTableInfo createTableInfo) throws UserException {
- String dbName = createTableInfo.getDbName();
- ExternalDatabase> db = dorisCatalog.getDbNullable(dbName);
- if (db == null) {
- throw new UserException("Failed to get database: '" + dbName + "' in catalog: " + dorisCatalog.getName());
- }
- String tableName = createTableInfo.getTableName();
- // 1. first, check if table exist in remote
- if (tableExist(db.getRemoteName(), tableName)) {
- if (createTableInfo.isIfNotExists()) {
- LOG.info("create table[{}] which already exists", tableName);
- return true;
- } else {
- ErrorReport.reportDdlException(ErrorCode.ERR_TABLE_EXISTS_ERROR, tableName);
- }
- }
-
- // 2. second, check if table exist in local.
- // This is because case sensibility issue, eg:
- // 1. lower_case_table_name = 1
- // 2. create table tbl1;
- // 3. create table TBL1; TBL1 does not exist in remote because the remote system is case-sensitive.
- // but because lower_case_table_name = 1, the table can not be created in Doris because it is conflict with
- // tbl1
- ExternalTable dorisTable = db.getTableNullable(tableName);
- if (dorisTable != null) {
- if (createTableInfo.isIfNotExists()) {
- LOG.info("create table[{}] which already exists", tableName);
- return true;
- } else {
- ErrorReport.reportDdlException(ErrorCode.ERR_TABLE_EXISTS_ERROR, tableName);
- }
- }
- List columns = createTableInfo.getColumnDefinitions();
- List collect = columns.stream()
- .map(col -> new StructField(col.getName(), col.getType().toCatalogDataType(),
- col.getComment(), col.isNullable()))
- .collect(Collectors.toList());
- StructType structType = new StructType(new ArrayList<>(collect));
- Schema schema = toPaimonSchema(structType, createTableInfo.getPartitionDesc(), createTableInfo.getProperties());
- try {
- catalog.createTable(new Identifier(createTableInfo.getDbName(), createTableInfo.getTableName()),
- schema, createTableInfo.isIfNotExists());
- } catch (TableAlreadyExistException | DatabaseNotExistException e) {
- throw new RuntimeException(e);
- }
- return false;
- }
-
- private Schema toPaimonSchema(StructType structType, PartitionDesc partitionDesc, Map properties) {
- Map normalizedProperties = new HashMap<>(properties);
- normalizedProperties.remove(PRIMARY_KEY_IDENTIFIER);
- normalizedProperties.remove(PROP_COMMENT);
- if (normalizedProperties.containsKey(PROP_LOCATION)) {
- String path = normalizedProperties.remove(PROP_LOCATION);
- normalizedProperties.put(CoreOptions.PATH.key(), path);
- }
-
- String pkAsString = properties.get(PRIMARY_KEY_IDENTIFIER);
- List primaryKeys = pkAsString == null ? Collections.emptyList() : Arrays.stream(pkAsString.split(","))
- .map(String::trim)
- .collect(Collectors.toList());
- List partitionKeys = partitionDesc == null ? new ArrayList<>() : partitionDesc.getPartitionColNames();
- Schema.Builder schemaBuilder = Schema.newBuilder()
- .options(normalizedProperties)
- .primaryKey(primaryKeys)
- .partitionKeys(partitionKeys)
- .comment(properties.getOrDefault(PROP_COMMENT, null));
- for (StructField field : structType.getFields()) {
- schemaBuilder.column(field.getName(),
- toPaimontype(field.getType()).copy(field.getContainsNull()),
- field.getComment());
- }
- return schemaBuilder.build();
- }
-
- private DataType toPaimontype(Type type) {
- return DorisTypeVisitor.visit(type, new DorisToPaimonTypeVisitor());
- }
-
- @Override
- public void afterCreateTable(String dbName, String tblName) {
- Optional> db = dorisCatalog.getDbForReplay(dbName);
- if (db.isPresent()) {
- db.get().resetMetaCacheNames();
- }
- LOG.info("after create table {}.{}.{}, is db exists: {}",
- dorisCatalog.getName(), dbName, tblName, db.isPresent());
- }
-
- @Override
- public void dropTableImpl(ExternalTable dorisTable, boolean ifExists) throws DdlException {
- try {
- executionAuthenticator.execute(() -> {
- performDropTable(dorisTable.getRemoteDbName(), dorisTable.getRemoteName(), ifExists);
- return null;
- });
- } catch (Exception e) {
- throw new DdlException(
- "Failed to drop table: " + dorisTable.getName() + ", error message is:" + e.getMessage(), e);
- }
- }
-
- private void performDropTable(String dBName, String tableName, boolean ifExists) throws DdlException {
- if (!tableExist(dBName, tableName)) {
- if (ifExists) {
- LOG.info("drop table[{}] which does not exist", tableName);
- return;
- } else {
- ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_TABLE, tableName, dBName);
- }
- }
- try {
- catalog.dropTable(Identifier.create(dBName, tableName), ifExists);
- } catch (TableNotExistException e) {
- throw new RuntimeException("table " + tableName + " does not exist");
- }
- }
-
- @Override
- public void afterDropTable(String dbName, String tblName) {
- Optional> db = dorisCatalog.getDbForReplay(dbName);
- db.ifPresent(externalDatabase -> externalDatabase.unregisterTable(tblName));
- LOG.info("after drop table {}.{}.{}. is db exists: {}",
- dorisCatalog.getName(), dbName, tblName, db.isPresent());
- }
-
- @Override
- public void truncateTableImpl(ExternalTable dorisTable, List partitions) throws DdlException {
- throw new UnsupportedOperationException("truncate table is not a supported operation!");
- }
-
- @Override
- public void createOrReplaceBranchImpl(ExternalTable dorisTable, CreateOrReplaceBranchInfo branchInfo)
- throws UserException {
- throw new UnsupportedOperationException("create or replace branch is not a supported operation!");
- }
-
- @Override
- public void createOrReplaceTagImpl(ExternalTable dorisTable, CreateOrReplaceTagInfo tagInfo) throws UserException {
- throw new UnsupportedOperationException("create or replace tag is not a supported operation!");
- }
-
- @Override
- public void dropTagImpl(ExternalTable dorisTable, DropTagInfo tagInfo) throws UserException {
- throw new UnsupportedOperationException("drop tag is not a supported operation!");
- }
-
- @Override
- public void dropBranchImpl(ExternalTable dorisTable, DropBranchInfo branchInfo) throws UserException {
- throw new UnsupportedOperationException("drop branch is not a supported operation!");
- }
-
- @Override
- public List listDatabaseNames() {
- try {
- return executionAuthenticator.execute(() -> new ArrayList<>(catalog.listDatabases()));
- } catch (Exception e) {
- throw new RuntimeException("Failed to list databases names, catalog name: " + dorisCatalog.getName(), e);
- }
- }
-
- @Override
- public List listTableNames(String db) {
- try {
- return executionAuthenticator.execute(() -> {
- List tableNames = new ArrayList<>();
- try {
- tableNames.addAll(catalog.listTables(db));
- } catch (DatabaseNotExistException e) {
- LOG.warn("DatabaseNotExistException", e);
- }
- return tableNames;
- });
- } catch (Exception e) {
- throw new RuntimeException("Failed to list table names, catalog name: " + dorisCatalog.getName(), e);
- }
- }
-
- @Override
- public boolean tableExist(String dbName, String tblName) {
- try {
- return executionAuthenticator.execute(() -> {
- try {
- catalog.getTable(Identifier.create(dbName, tblName));
- return true;
- } catch (TableNotExistException e) {
- return false;
- }
- });
-
- } catch (Exception e) {
- throw new RuntimeException("Failed to check table existence, catalog name: " + dorisCatalog.getName()
- + "error message is:" + ExceptionUtils.getRootCauseMessage(e), e);
- }
- }
-
- @Override
- public boolean databaseExist(String dbName) {
- try {
- return executionAuthenticator.execute(() -> {
- try {
- catalog.getDatabase(dbName);
- return true;
- } catch (DatabaseNotExistException e) {
- return false;
- }
- });
- } catch (Exception e) {
- throw new RuntimeException("Failed to check database exist, error message is:" + e.getMessage(), e);
- }
- }
-
- public Catalog getCatalog() {
- return catalog;
- }
-
- @Override
- public void close() {
- if (catalog != null) {
- catalog = null;
- }
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonMvccSnapshot.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonMvccSnapshot.java
deleted file mode 100644
index 2307e91adb3911..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonMvccSnapshot.java
+++ /dev/null
@@ -1,32 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.doris.datasource.mvcc.MvccSnapshot;
-
-public class PaimonMvccSnapshot implements MvccSnapshot {
- private final PaimonSnapshotCacheValue snapshotCacheValue;
-
- public PaimonMvccSnapshot(PaimonSnapshotCacheValue snapshotCacheValue) {
- this.snapshotCacheValue = snapshotCacheValue;
- }
-
- public PaimonSnapshotCacheValue getSnapshotCacheValue() {
- return snapshotCacheValue;
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonPartition.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonPartition.java
deleted file mode 100644
index 545448199b3375..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonPartition.java
+++ /dev/null
@@ -1,61 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-// https://paimon.apache.org/docs/0.9/maintenance/system-tables/#partitions-table
-public class PaimonPartition {
- // Partition values, for example: [1, dd]
- private final String partitionValues;
- // The amount of data in the partition
- private final long recordCount;
- // Partition file size
- private final long fileSizeInBytes;
- // Number of partition files
- private final long fileCount;
- // Last update time of partition
- private final long lastUpdateTime;
-
- public PaimonPartition(String partitionValues, long recordCount, long fileSizeInBytes, long fileCount,
- long lastUpdateTime) {
- this.partitionValues = partitionValues;
- this.recordCount = recordCount;
- this.fileSizeInBytes = fileSizeInBytes;
- this.fileCount = fileCount;
- this.lastUpdateTime = lastUpdateTime;
- }
-
- public String getPartitionValues() {
- return partitionValues;
- }
-
- public long getRecordCount() {
- return recordCount;
- }
-
- public long getFileSizeInBytes() {
- return fileSizeInBytes;
- }
-
- public long getFileCount() {
- return fileCount;
- }
-
- public long getLastUpdateTime() {
- return lastUpdateTime;
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonPartitionInfo.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonPartitionInfo.java
deleted file mode 100644
index a6339ef5155e15..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonPartitionInfo.java
+++ /dev/null
@@ -1,56 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.doris.catalog.PartitionItem;
-
-import com.google.common.collect.Maps;
-import org.apache.paimon.partition.Partition;
-
-import java.util.Map;
-
-public class PaimonPartitionInfo {
- public static final PaimonPartitionInfo EMPTY = new PaimonPartitionInfo();
-
- private final Map nameToPartitionItem;
- private final Map nameToPartition;
-
- private PaimonPartitionInfo() {
- this.nameToPartitionItem = Maps.newHashMap();
- this.nameToPartition = Maps.newHashMap();
- }
-
- public PaimonPartitionInfo(Map nameToPartitionItem,
- Map nameToPartition) {
- this.nameToPartitionItem = nameToPartitionItem;
- this.nameToPartition = nameToPartition;
- }
-
- public Map getNameToPartitionItem() {
- return nameToPartitionItem;
- }
-
- public Map getNameToPartition() {
- return nameToPartition;
- }
-
- public boolean isPartitionInvalid() {
- // when transfer to partitionItem failed, will not equal
- return nameToPartitionItem.size() != nameToPartition.size();
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonRestExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonRestExternalCatalog.java
deleted file mode 100644
index 6360a61a00d7f6..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonRestExternalCatalog.java
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import java.util.Map;
-
-@Deprecated
-public class PaimonRestExternalCatalog extends PaimonExternalCatalog {
-
- public PaimonRestExternalCatalog(long catalogId, String name, String resource,
- Map props, String comment) {
- super(catalogId, name, resource, props, comment);
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSchemaCacheKey.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSchemaCacheKey.java
deleted file mode 100644
index 4eccb269c2fe56..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSchemaCacheKey.java
+++ /dev/null
@@ -1,56 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.doris.datasource.NameMapping;
-import org.apache.doris.datasource.SchemaCacheKey;
-
-import com.google.common.base.Objects;
-
-public class PaimonSchemaCacheKey extends SchemaCacheKey {
- private final long schemaId;
-
- public PaimonSchemaCacheKey(NameMapping nameMapping, long schemaId) {
- super(nameMapping);
- this.schemaId = schemaId;
- }
-
- public long getSchemaId() {
- return schemaId;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof PaimonSchemaCacheKey)) {
- return false;
- }
- if (!super.equals(o)) {
- return false;
- }
- PaimonSchemaCacheKey that = (PaimonSchemaCacheKey) o;
- return schemaId == that.schemaId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), schemaId);
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSchemaCacheValue.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSchemaCacheValue.java
deleted file mode 100644
index e931b52336ba8f..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSchemaCacheValue.java
+++ /dev/null
@@ -1,47 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.doris.catalog.Column;
-import org.apache.doris.datasource.SchemaCacheValue;
-
-import org.apache.paimon.schema.TableSchema;
-
-import java.util.List;
-
-public class PaimonSchemaCacheValue extends SchemaCacheValue {
-
- private List partitionColumns;
-
- private TableSchema tableSchema;
- // Caching TableSchema can reduce the reading of schema files and json parsing.
-
- public PaimonSchemaCacheValue(List schema, List partitionColumns, TableSchema tableSchema) {
- super(schema);
- this.partitionColumns = partitionColumns;
- this.tableSchema = tableSchema;
- }
-
- public List getPartitionColumns() {
- return partitionColumns;
- }
-
- public TableSchema getTableSchema() {
- return tableSchema;
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSnapshot.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSnapshot.java
deleted file mode 100644
index 96f32370d999b7..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSnapshot.java
+++ /dev/null
@@ -1,45 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.paimon.table.Table;
-
-public class PaimonSnapshot {
- public static long INVALID_SNAPSHOT_ID = -1;
- private final long snapshotId;
- private final long schemaId;
- private final Table table;
-
- public PaimonSnapshot(long snapshotId, long schemaId, Table table) {
- this.snapshotId = snapshotId;
- this.schemaId = schemaId;
- this.table = table;
- }
-
- public long getSnapshotId() {
- return snapshotId;
- }
-
- public long getSchemaId() {
- return schemaId;
- }
-
- public Table getTable() {
- return table;
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSnapshotCacheValue.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSnapshotCacheValue.java
deleted file mode 100644
index c50ecdabfde3df..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSnapshotCacheValue.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-public class PaimonSnapshotCacheValue {
-
- private final PaimonPartitionInfo partitionInfo;
- private final PaimonSnapshot snapshot;
-
- public PaimonSnapshotCacheValue(PaimonPartitionInfo partitionInfo, PaimonSnapshot snapshot) {
- this.partitionInfo = partitionInfo;
- this.snapshot = snapshot;
- }
-
- public PaimonPartitionInfo getPartitionInfo() {
- return partitionInfo;
- }
-
- public PaimonSnapshot getSnapshot() {
- return snapshot;
- }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSysExternalTable.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSysExternalTable.java
deleted file mode 100644
index b6999b7c50c558..00000000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonSysExternalTable.java
+++ /dev/null
@@ -1,277 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.datasource.paimon;
-
-import org.apache.doris.catalog.Column;
-import org.apache.doris.catalog.TableIf;
-import org.apache.doris.datasource.ExternalTable;
-import org.apache.doris.datasource.NameMapping;
-import org.apache.doris.datasource.SchemaCacheKey;
-import org.apache.doris.datasource.SchemaCacheValue;
-import org.apache.doris.datasource.systable.SysTable;
-import org.apache.doris.statistics.AnalysisInfo;
-import org.apache.doris.statistics.BaseAnalysisTask;
-import org.apache.doris.statistics.ExternalAnalysisTask;
-import org.apache.doris.thrift.THiveTable;
-import org.apache.doris.thrift.TTableDescriptor;
-import org.apache.doris.thrift.TTableType;
-
-import com.google.common.collect.Lists;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.paimon.table.DataTable;
-import org.apache.paimon.table.Table;
-import org.apache.paimon.table.source.Split;
-import org.apache.paimon.types.DataField;
-import org.apache.paimon.types.DataTypeRoot;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * Represents a Paimon system table (e.g., snapshots, binlog, audit_log) that wraps a source data table.
- *
- *
This class enables system tables to be queried using the native table execution path
- * (FileQueryScanNode) instead of the TVF path (MetadataScanNode). This provides:
- *
- *
Unified execution path with regular tables
- *
Native vectorized reading for data-oriented system tables
- *
Better integration with query optimization
- *
- *
- *
System tables are classified into two categories:
- *
- *
Data tables (e.g., binlog, audit_log, ro): Read actual ORC/Parquet data files