924060929 opened a new pull request, #70884:
URL: https://github.com/apache/doris/pull/70884
### Background
`PluginDrivenMvccExternalTable` supports deferring engine-side partition
view materialization for connectors whose scan planner prunes files natively
from snapshot manifests (`supportsNativePartitionPlanning`), and supports
validating SQL result cache entries and generation-keyed partition views from
connector metadata versions (`getSqlCacheVersion` and
`getPartitionViewVersion`) without enumerating every partition (#69299). Paimon
data-table scans already prune manifests and data files natively in
`PaimonScanPlanProvider`, while `PaimonConnectorMetadata` still inherited the
SPI defaults (`false` and `Optional.empty()`), forcing every ordinary Paimon
scan and SQL cache check to materialize all partitions into Doris
`PartitionItem`s.
### What problem does this PR solve?
Issue Number: None
Related PR: #69299 (introduced `supportsNativePartitionPlanning`,
`getSqlCacheVersion`, and `getPartitionViewVersion` for Iceberg)
PR Type: Enhancement
Problem Summary: Ordinary Paimon data-table queries and SQL result-cache
checks eagerly listed and converted every partition on FE even though
`PaimonScanPlanProvider` already prunes partitions and files natively from
pinned Paimon snapshots. Implement `supportsNativePartitionPlanning`,
`getSqlCacheVersion`, and `getPartitionViewVersion` in
`PaimonConnectorMetadata` (backed by `PaimonSchemaPin` and `PaimonScanParams`),
and add the session variable `enable_paimon_internal_partition_pruning`
(default `false`) as an opt-in switch for Doris FE partition pruning. Existing
materialized view planning, `SHOW PARTITIONS`, and partition metadata rules
continue to load the full partition view on demand.
### Details
- **Change map:** 295 lines of production code across 5 Java files, 451
lines of unit tests in 2 test files, and 3 lines of connector documentation in
`fe/fe-connector/README.md`.
- `SessionVariable.java` (+8): adds
`enable_paimon_internal_partition_pruning` (default `false`).
- `PaimonScanParams.java` (+49): exposes `boundSchemaId`,
`hasPinnedVersion`, `supportsPartitionViewVersion`, and `canonicalCacheOptions`
for pinned snapshot/tag/empty/options handles.
- `PaimonSchemaPin.java` (+196): resolves deterministic SHA-256 SQL cache
and partition view version digests across `DataTable`,
`DelegatedFileStoreTable`, `FallbackReadFileStoreTable`, and nested
`ChainGroupReadTable` branches, covering snapshot digests, schema digests,
retained `Tag` metadata (including expired underlying snapshots), empty scans,
physical path recreation, and `query.auth.enabled` rejection.
- `PaimonCatalogOps.java` & `PaimonConnectorMetadata.java` (+50): wires
`resolveSqlCacheVersion`, `supportsNativePartitionPlanning`,
`getSqlCacheVersion` (failing loud on unsupported handles so `SqlCacheContext`
disables SQL caching without falling back to partition enumeration), and
`getPartitionViewVersion` (requiring a live statement scope and
metadata-neutral options).
- `PaimonNativePartitionAndCacheVersionTest.java` &
`RecordingPaimonCatalogOps.java` (+465): unit tests covering native planning
toggle, system tables, snapshot/schema evolution, rollback + snapshot-id reuse,
drop/recreate at the same path, tags with expired snapshot files, branches,
fallback branches, chain-table delta branches, and `query.auth.enabled`.
- **Before and after:** Before this change, every ordinary Paimon query and
SQL cache check materialized all Paimon partitions into FE `PartitionItem`s;
after this change, ordinary Paimon data-table scans defer the FE partition view
(`SelectedPartitions.NATIVE`) and SQL cache / partition view cache key off
pinned snapshot + schema digests without listing partitions.
- **Configs and defaults:** Adds session variable
`enable_paimon_internal_partition_pruning` with default `false` (matching
`enable_iceberg_internal_partition_pruning`).
- **Behavior change:** Ordinary Paimon data-table scans use native Paimon
manifest/file pruning by default (`EXPLAIN` shows native partition planning
unless `enable_paimon_internal_partition_pruning=true`), and Paimon SQL result
caching validates pinned snapshot/tag/branch/schema versions directly.
- **Impact on existing users:** Queries on Paimon tables with large
partition counts avoid FE partition enumeration overhead during planning and
SQL cache validation; users relying on Doris FE-side partition pruning
expressions can set `SET enable_paimon_internal_partition_pruning = true`.
### Testing
- Ran `./run-fe-ut.sh --run
"org.apache.doris.connector.paimon.PaimonNativePartitionAndCacheVersionTest,org.apache.doris.connector.paimon.PaimonConnectorMetadataMvccTest,org.apache.doris.connector.paimon.PaimonConnectorMetadataPartitionViewCacheTest,org.apache.doris.connector.paimon.PaimonConnectorMetadataPartitionTest,org.apache.doris.connector.paimon.PaimonConnectorMetadataReadAuthTest,org.apache.doris.connector.ConnectorSessionImplTest,org.apache.doris.datasource.mvcc.PluginDrivenMvccExternalTableTest,org.apache.doris.nereids.SqlCacheContextPluginTableTest,org.apache.doris.common.cache.NereidsSqlCacheManagerPluginTableTest"`
locally (all passed).
- Ran `mvn test` and Checkstyle (`validate` / `checkstyle:check`) on
`fe-connector-paimon` and `fe-core`, plus
`./build-support/check-fe-connector-imports.sh` and
`./build-support/check-fe-core-metadata-funnel.sh` locally (0 violations).
### Release note
Paimon ordinary data-table scans defer FE partition view conversion and rely
on Paimon native manifest/file pruning by default
(`enable_paimon_internal_partition_pruning = false`), and Paimon SQL result
caching validates pinned snapshot, tag, branch, and schema versions without
enumerating partitions.
### Check List (For Author)
- Test: Unit Test (`run-fe-ut.sh`, Checkstyle, and FE connector architecture
gates)
- Behavior changed: Yes (see Details)
- Does this need documentation: Yes (updated `fe/fe-connector/README.md`;
session variable `enable_paimon_internal_partition_pruning` is self-documented
via `@VarAttr`)
- Pre-submission status: Ready
### AI Disclosure
- Tool: Antigravity
- Generated: Code, unit tests, and PR description
- Human review: Design, connector invariants, and test coverage reviewed
with the author
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]