Repository navigation
Description
Background
Currently, Doris supports querying Paimon system tables (e.g., table$snapshots, table$partitions) through the Table-Valued Function (TVF) path. The execution flow is:
SQL: SELECT * FROM catalog.db.table$snapshots
→ MetadataScanNode → TVF → JNI Scanner → Paimon SDK
This approach works well for metadata-oriented system tables (snapshots, manifests, partitions, etc.) that return small result sets from metadata files.
However, for data-oriented system tables like binlog, audit_log, and ro (read-optimized), the current JNI-based approach has significant performance limitations:
- Data Source Difference: Unlike metadata tables,
binlog/audit_log/roread actual data files (ORC/Parquet), not metadata files - JNI Overhead: Large data volumes suffer from JNI serialization/deserialization overhead
- Missing Native Optimizations: Cannot leverage Doris's native vectorized ORC/Parquet readers and predicate pushdown optimizations
Paimon System Table Classification
| Category | System Tables | Data Source | Current Path | Proposed Path |
|---|---|---|---|---|
| Metadata | snapshots, manifests, partitions, schemas, options, tags, branches, files, buckets, etc. | Metadata files | TVF + JNI | Keep as-is |
| Data | binlog, audit_log, ro | Actual data files (ORC/Parquet) | TVF + JNI | Native Read |
Paimon binlog/audit_log Implementation Analysis
In Paimon's codebase, BinlogTable and AuditLogTable are special:
- They implement
DataTableinterface (not justReadonlyTable) - They wrap the underlying
FileStoreTableand read actual data files - They reuse
DataSplitfrom the source table - The underlying storage format is ORC/Parquet
Key implementation files in Paimon:
paimon-core/.../table/system/BinlogTable.java- extends AuditLogTablepaimon-core/.../table/system/AuditLogTable.java- wraps FileStoreTable
This makes them ideal candidates for native reading in Doris.
Proposal
Refactor the system table query path to support native reading for data-oriented Paimon system tables.
Phase 1: FE Refactoring
Goal: Route binlog/audit_log/ro queries through PaimonScanNode instead of MetadataScanNode.
-
Extend
SysTableinterface- Add
useNativeTablePath()method to distinguish execution paths - Add
getSchema()method for native path schema retrieval
- Add
-
Create
PaimonSysExternalTable- New class extending
PaimonExternalTable - Wraps source table with system table type
- Returns Paimon
BinlogTable/AuditLogTableinstance fromgetPaimonTable()
- New class extending
-
Modify
BindRelation- Check
useNativeTablePath()before creating TVF relation - Create
LogicalFileScanfor native-path system tables
- Check
-
Adapt
PaimonScanNode- Support
PaimonSysExternalTableas scan source - Generate splits from system table's
ReadBuilder - Pass system table type to BE via
TPaimonFileDesc
- Support
Phase 2: BE Native Reader Implementation
Goal: Implement native readers for binlog/audit_log with row transformation logic.
-
Extend Thrift definitions
- Add
sys_table_typefield toTPaimonFileDesc - Add
force_keep_deleteandis_streamingflags
- Add
-
Implement
PaimonAuditLogReader- Wrap native ORC/Parquet reader
- Add
rowkindcolumn based on delete vectors - Support
forceKeepDeletesemantics
-
Implement
PaimonBinlogReader- Extend
PaimonAuditLogReader - Convert columns to array types
- Pack UPDATE_BEFORE/UPDATE_AFTER pairs (streaming mode)
- Extend
Expected Architecture
SQL: SELECT * FROM catalog.db.table$binlog
↓
BindRelation (useNativeTablePath=true)
↓
PaimonSysExternalTable (wraps source table)
↓
PaimonScanNode (reuse existing logic)
- Serialize BinlogTable
- Get DataSplits from BinlogTable
- Set sys_table_type="binlog"
↓
BE: PaimonBinlogReader
- Native ORC/Parquet reading
- Add rowkind column
- Array conversion for binlog
- Changelog packing (streaming)
Benefits
- Performance: Leverage native vectorized readers, avoid JNI overhead
- Predicate Pushdown: Native readers support efficient filtering
- Resource Efficiency: Reduced memory copying between Java and C++
- Consistency: Unified execution path with regular Paimon tables
- Scalability: Better performance for large-scale CDC scenarios
Tasks
- Phase 1.1: Extend
SysTableinterface withuseNativeTablePath() - Phase 1.2: Implement
PaimonSysExternalTableclass - Phase 1.3: Modify
BindRelationto support native path routing - Phase 1.4: Adapt
PaimonScanNodefor system tables - Phase 2.1: Extend Thrift definitions for system table params
- Phase 2.2: Implement
PaimonAuditLogReader - Phase 2.3: Implement
PaimonBinlogReader - Phase 2.4: Add regression tests
Related
- Paimon BinlogTable: https://github.com/apache/paimon/blob/master/paimon-core/src/main/java/org/apache/paimon/table/system/BinlogTable.java
- Paimon AuditLogTable: https://github.com/apache/paimon/blob/master/paimon-core/src/main/java/org/apache/paimon/table/system/AuditLogTable.java
Use Case
This feature is particularly valuable for:
- Real-time CDC pipelines reading Paimon binlog
- Data auditing scenarios with large audit_log tables
- Read-optimized queries on Paimon tables with
rosystem table
Activity
[Feature](paimon) Refactor Paimon system tables to use native table e…
[Feature](paimon) Refactor Paimon system tables to use native table e…