feat: add native MIN/MAX Parquet reader filtering 1/n #7598
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #7598"
general
weight: 0.35
sunchao
Which issue does this PR close?
Part 1 of #5774; this PR does not close the issue. The three-PR plan is in this issue comment.
Rationale for this change
A partial
MIN(x)orMAX(x)can tighten a bound while consuming Parquet input and skip later row groups that cannot improve the result. DataFusion already updates that bound, but Comet needs to connect its producer to the native reader and scope the mutable state to one execution.What changes are included in this PR?
Add the internal
MinMaxReaderFilterExecwith the existing Parquet reader attachment. It accepts one unfiltered, non-distinct DataFusion MIN/MAX over a direct signed-integer column, with no grouping, in Partial mode, and one native input partition. Standalone projections, filters, limits, non-Parquet inputs, pushed scan predicates, and computed expressions in scan projections remain ineligible. Direct-column scan projections retain the existing file-column mapping.Each execution constructs a fresh aggregate and uses its DataFusion-created predicate and accumulator-bound state. Aggregate metric handles and attachment counters belong to the wrapper; reader pruning and byte metrics stay with the scan. Unsupported reader attachment retains ordinary aggregation. The per-file schema guard preserves required-field validation for nullable physical columns and missing fields filled with NULL defaults. Nullable fields and non-NULL defaults remain eligible for pruning. MIN/MAX and TopK share metric handoff and runtime-state release on completion, error, or cancellation.
DataFusion 55.2 rechecks every unread row group at each boundary. Before executing the aggregate, inspect footers through the existing reader factory with Comet's 512 KiB hint unless the file provides an override and enable runtime pruning only when every file has at most 64 row groups. An oversized file, unavailable reader factory, or failed metadata inspection selects ordinary aggregation for the execution. The row-group limit is conservative for file ranges and stays until the upstream reader supports bounded pruning. Scans configured with decryption properties or a native key factory bypass preflight entirely and retain ordinary aggregation, avoiding an extra encrypted-footer read without the key.
Preflight hands its loaded readers and footers directly to the execution's scan, including ordinary fallback, so disabled or undersized shared caches do not cause duplicate footer reads. It stops when retained metadata exceeds 8 MiB and falls back, retaining the footer that crosses the limit for reuse. Readers are consumed by file occurrence and released with the runtime stream; repeated paths and Bloom-filter reader replacement cannot consume another occurrence's footer. Preflight still moves footer I/O ahead of the first output batch.
This is the native building block only: no Spark configuration, serialization, or planner integration is included, and existing Spark execution is unchanged. Those changes, including handling identity casts in MIN/MAX arguments, belong to PR 2. Only the
try_newentry point carries a temporary dead-code allowance until that integration lands.How are these changes tested?
Seventeen MIN/MAX tests cover:
Tests live in child modules grouped by behavior. MIN/MAX and TopK share Parquet/session fixtures and footer-statistics helpers. Broader type comparisons with Spark belong to the SQL tests in PR 2.
Validation:
cargo test --locked -p datafusion-comet --lib execution::operators::dynamic_filter::: 75 passed, including MIN/MAX and TopK.rustfmt --checkandgit diff --check: passed.dev/release/check-rat.sh HEAD: passed on the final source archive.cargo clippy --locked --color=never --all-targets --workspace -- -D warnings: passed.c91a1203fhead passed, including Comet, Spark SQL 4.1, Iceberg 1.11, TPC-H, and TPC-DS.