← Back to Pull requests

feat: integrate MIN/MAX reader filtering with Spark 2/n #7657

Closed
unknown closed this pull request without merging on Nov 19, 2026 02:43 UTC
View on GitHub
unknown unknown commented on Nov 16, 2026 21:30 UTC
Author

Which issue does this PR close?

Part 2 of #5774, following the merged native reader-filter foundation in #7598. This PR does not close the issue.

Rationale for this change

For SELECT MIN(id) FROM parquet_table, each Spark task can tighten its bound as it reads input and skip later row groups that cannot improve its partial result. The final aggregate combines those partial results as usual.

What changes are included in this PR?

Add spark.comet.exec.aggregate.dynamicFilter.enabled, disabled by default. Capture the flag only for nonempty, ungrouped aggregates whose expressions all use raw-input Partial mode, and include it in Spark plan equality so execution and plan reuse preserve the setting chosen during planning.

When enabled, the Rust planner uses MinMaxReaderFilterExec for the narrow subset supported by #7598: one unfiltered MIN or MAX over a direct signed-integer column, without grouping, in raw-input Partial mode over an eligible native Parquet scan. Bounds remain local to each execution. Unsupported plans retain ordinary aggregation; Final/PartialMerge stages and JVM boundaries remain ineligible.

Only the enabled path removes a matching integer column's identity cast, allowing DataFusion to recognize the bound producer. The disabled path retains that cast and avoids DataFusion's otherwise unconsumed bound updates. Spark displays reader-filter attachment counters only on aggregates whose captured flag is enabled; pruning and byte metrics remain on scans.

Register the new Spark suite in Linux and macOS CI. Benchmarks and detailed tuning documentation remain for PR 3; the configuration description documents the current limits.

How are these changes tested?

  • CometMinMaxSuite: 9 tests passed on Spark 4.1.3. Filtering off/on matches Spark for all four signed integer types, multiple Spark partitions with AQE off/on, and unsupported plans. The eight-row-group fixture includes an all-null group and actual type minimum/maximum values after bounds improve, and asserts dynamic pruning plus row/byte reductions. Tests also cover captured flags, conditional metrics, canonicalization, DISTINCT and merge stages, and a Comet Partial above a JVM-to-Arrow boundary with no reader attachment.

  • min_max_dynamic_filter.sql: both config-matrix variants passed, covering empty, all-null, and duplicate/mixed input with separate MIN and MAX queries.

  • Native planner tests: 128 passed, including three new tests for serialized flag handling, pruning and metric ownership, ordinary stage/JVM fallback, retained real casts, and no dynamic expressions when disabled.

  • Existing dynamic-filter tests: 75 passed.

  • Workspace Clippy with warnings denied, Scala style checks, Spotless, Rust formatting, and whitespace checks passed.

  • Two independent source reviews completed for each of the two review-fix commits.

  • Source-archive license check (dev/release/check-rat.sh HEAD) passed. The raw text fixture from #6784 has an exact-path RAT exemption, consistent with the existing data-fixture exclusions.
  • Diff: 381 lines (+285 / -96) across 4 files Reviewer: sunchao Review duration: 3193m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 381 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.356
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #7657"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.0% (MEDIUM) · Higher = larger blast radius
    43.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.0% · Safe to merge
    17.0%