← Back to Pull requests

fix: pass the session batch size to the native FilterExec #7280

Closed
unknown closed this pull request without merging on Nov 01, 2026 04:39 UTC
View on GitHub
unknown unknown commented on Oct 28, 2026 00:01 UTC
Author

Which issue does this PR close?

Closes #7268.

Part of #7267. That epic stays open: this change only helps when spark.comet.batchSize is lowered, and it doesn't remove the 2 GiB limit.

Rationale for this change

Comet builds the native filter with FilterExec::try_new and never sets its batch size. FilterExec merges small output batches into bigger ones, and without a batch size it uses DataFusion's built-in default of 8192 rows. DataFusion's own physical planner passes the session batch size here; Comet's planner skipped that step.

So the filter ignores spark.comet.batchSize. The scan honors the setting and emits small batches, then the filter merges them back up to 8192 rows. With large string or binary values (for example blobs of a few hundred KB each), one merged column can pass Arrow's 2 GiB limit for 32-bit offsets. The query then fails with:

org.apache.comet.CometNativeException: Offset overflow error: <n>

Lowering spark.comet.batchSize is the natural workaround, but today it has no effect on this path, even at batchSize=1.

What changes are included in this PR?

  • The planner builds the filter with FilterExecBuilder and the session batch size, the same way DataFusion's planner does.

  • Every place that later rebuilds the filter keeps the value. That covers the projection-pruning rebuild and the CometFilterExec wrapper used for join probe sides. I checked that this match arm is the only place Comet creates a FilterExec.

  • Adds a small CometFilterExec::batch_size() accessor, so a test can check the wrapped filter.
  • Behavior change: the filter now follows spark.comet.batchSize in both directions.

  • At the default of 8192, nothing changes at runtime.

  • Lowering it now bounds the filter's output. That gives users with large values a working workaround (for ~1 MB values, about 1024 or less).

  • Raising it above 8192 now gives larger filter output batches, as other operators already do with the session value.
  • This is still a row-count limit. At 8192 rows, any string/binary column averaging more than about 256 KiB per value can still overflow. A byte limit in the coalescer (#7271) is the fix that doesn't depend on row counts. Other operators and batch sources with the same problem are tracked in #7267.

    How are these changes tested?

    Rust tests. Each one fails without the fix and passes with it:

  • filter_output_respects_session_batch_size: with a session batch size of 2, five 1-row batches that all pass the filter must come out as [2, 2, 1]. Without the fix they merge into one 5-row batch. The batches include a string column with NULL, empty and multi-byte values, and the test checks every value comes through in order.

  • projection_prunes_filter_output_and_preserves_metrics (existing test): now plans with a session batch size of 5 and asserts the filter keeps it, with and without projection pruning.

  • probe_filters_keep_session_batch_size (planner/join.rs): prepares a filter -> projection -> filter plan as a join probe side, and checks both wrapped CometFilterExecs keep the session batch size.
  • SQL file test operators/filter_varlen_values.sql: with spark.comet.batchSize=4, filters over binary, string, array<struct<binary, string>> and map<string, binary> columns, including NULL, empty and non-ASCII values, compared with Spark. One filter keeps about one row in three, so every batch gets merged. This test checks that merged batches match Spark. It passes with or without the fix, because SQL can't see batch sizes; the Rust tests are the regression guard.

    Diff: 447 lines (+335 / -112) across 5 files Reviewer: rich7420 Review duration: 6038m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.45) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 447 lines diff across 5 files
    0.45
    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%
    56%
    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.365
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #7280"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 45.4% (MEDIUM) · Higher = larger blast radius
    45.4%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 19.6% · Safe to merge
    19.6%