← Back to Pull requests

Cap GPU Parquet metadata-only batches by batch size limits [databricks] #16737

Closed
unknown closed this pull request without merging on Nov 13, 2026 21:51 UTC
View on GitHub
unknown unknown commented on Nov 04, 2026 19:09 UTC
Author

Fixes #16617.

Description

When none of the requested columns exist in a Parquet file, the GPU readers build one all null batch covering every row of the split. The batch size ignores spark.rapids.sql.reader.batchSizeRows and spark.rapids.sql.batchSizeBytes, so large splits can cause GPU OOM. In the multithreaded reader, combining also merged such entries without limit, and a combined row count above Int.MaxValue failed with ArithmeticException.

To fix this, each metadata only batch is now capped at min(batchSizeRows, rows that fit in batchSizeBytes). The byte limit is estimated with GpuBatchUtils.estimateGpuMemory over the output schema, including partition columns.

  • A new GpuNullBatchIterator lazily produces null batches up to the cap, under the GPU semaphore and withRetryNoSplit. The semaphore is acquired for every batch, including an empty read schema. Partition columns may be added on the GPU afterwards, and the per file and coalescing readers already acquired it unconditionally. The multithreaded reader used to skip it for a plain count(*)

  • Per file reader: Uses the iterator, and its cap includes partition columns. partitionSchema and targetBatchSizeBytes are passed to AbstractParquetPartitionReader. A per file chunk is already bounded by populateCurrentBlockChunk (a single row group is capped at Int.MaxValue rows, other row groups are added only up to maxReadBatchSizeRows). So per file streaming above Int.MaxValue rows never occurs. computeNumRowsAlive is widened to Long only for consistency.

  • Coalescing reader: Uses the iterator with a cap that includes partition columns. MultiFileCoalescingPartitionReaderBase now takes targetBatchSizeBytes (passed by the Parquet, ORC and Avro readers) so it can cap metadata-only batches. This base class is shared with ORC and Avro, so their metadata only reads are now capped too.

  • Multithreaded reader: Metadata only entries are combined only while the total stays within the cap. Larger splits, including those above Int.MaxValue rows, stream as multiple batches through GpuColumnarBatchWithPartitionValuesIterator, which attaches partition values across batch boundaries.
  • Testing

  • Unit tests:

  • - GpuNullBatchIteratorSuite covers the cap math, lazy and Long sized iteration, and that the semaphore is held for an empty schema.
    - ParquetCombineSuite covers combining at and past the cap, oversized entries, a split above Int.MaxValue rows, and a per-file read of two Int.MaxValue-row groups capped to the byte limit.
  • End to end tests compare against CPU for PERFILE, COALESCING and MULTITHREADED. In ParquetScanSuite they check that every batch is at most the cap and the total is exact, under a small byte target, a row limit, and OOM injection. Other tests cover a partition only read and LIMIT stopping early.

  • OrcScanSuite adds an ORC coalescing test with the same per batch checks. Avro inherits the cap through the shared base class and has no test of its own.

  • Integration test test_read_parquet_with_empty_clipped_schema_small_batches added.
  • Performance The AB run used a 3.5.7 distribution on a Spark2a GPU cluster over NDS SF3k Parquet. It was counterbalanced, with 10 samples per jar and one warm-up iteration.

    The workload scans the NDS SF3k store_sales Parquet table through views that declare columns not present in the files (two INT columns, then three BIGINT columns). It runs count(...) over each view, so every row comes back as an all null batch with nothing decoded. A normal two column count over store_sales serves as the control. The two missing column views are the metadata-only path this change affects.

    | Query | Old (ms) | New (ms) | Median speedup | p |
    |---|---|---|---|---|
    | metadata only scan, int | 964 | 972 | 0.99x | 0.79 |
    | metadata only scan, long | 867 | 848 | 1.02x | 0.74 |
    | normal scan (control) | 1646 | 1604 | 1.03x | 0.47 |

    Checklists

    Documentation

  • Updated for new or modified user-facing features or behaviors

  • No user-facing change
  • Testing

  • Added or modified tests to cover new code paths

  • Covered by existing tests

  • (Please provide the names of the existing tests in the PR description.)
  • Not required
  • Performance

  • Tests ran and results are added in the PR description

  • Issue filed with a link in the PR description

  • Not required
  • Diff: 556 lines (+417 / -139) across 6 files Reviewer: sdrp713 Review duration: 13122m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 556 lines diff across 6 files
    0.48
    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.378
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #16737"
    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: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    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: 19% · Safe to merge
    19%