PaimonSysTable.java
// 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.systable;
import org.apache.doris.datasource.ExternalTable;
import org.apache.doris.datasource.paimon.PaimonExternalTable;
import org.apache.paimon.table.system.SystemTableLoader;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* System table type for Paimon system tables.
*
* <p>Paimon system tables are classified into two categories:
* <ul>
* <li><b>Data tables</b> (binlog, audit_log, ro): Read actual ORC/Parquet data files,
* benefit from native vectorized readers</li>
* <li><b>Metadata tables</b> (snapshots, partitions, etc.): Read metadata/manifest files,
* use JNI readers</li>
* </ul>
*
* <p>All Paimon system tables use the native table execution path (FileQueryScanNode)
* instead of the TVF path (MetadataScanNode).
*/
public class PaimonSysTable extends NativeSysTableType {
/**
* Data-oriented system tables that read actual data files (ORC/Parquet).
* These tables wrap the underlying FileStoreTable and benefit from native vectorized readers.
*/
private static final Set<String> DATA_SYS_TABLES = new HashSet<>(Arrays.asList("binlog", "audit_log", "ro"));
/**
* All supported Paimon system tables (both data and metadata).
* Key is the system table name (e.g., "snapshots", "binlog").
*/
public static final Map<String, SysTableType> SUPPORTED_SYS_TABLES = Collections.unmodifiableMap(
SystemTableLoader.SYSTEM_TABLES.stream()
.map(PaimonSysTable::new)
.collect(Collectors.toMap(SysTableType::getSysTableName, Function.identity())));
private final String tableName;
private PaimonSysTable(String tableName) {
super(tableName);
this.tableName = tableName;
}
/**
* Check if a system table type is a data-oriented system table.
*
* @param sysTableType the system table type name
* @return true if it's a data system table (binlog, audit_log, ro)
*/
public static boolean isDataSysTable(String sysTableType) {
return DATA_SYS_TABLES.contains(sysTableType);
}
/**
* Returns true if this system table reads actual data files.
* binlog, audit_log, and ro tables read ORC/Parquet data files.
*/
@Override
public boolean isDataTable() {
return DATA_SYS_TABLES.contains(tableName);
}
@Override
public ExternalTable createSysExternalTable(ExternalTable sourceTable) {
if (!(sourceTable instanceof PaimonExternalTable)) {
throw new IllegalArgumentException(
"Expected PaimonExternalTable but got " + sourceTable.getClass().getSimpleName());
}
return new PaimonSysExternalTable((PaimonExternalTable) sourceTable, getSysTableName());
}
}