← Back to Pull requests

Fix ORC corruption when compression block sizes differ[reduced-it] #17037

Closed
unknown closed this pull request without merging on Nov 20, 2026 09:08 UTC
View on GitHub
unknown unknown commented on Nov 19, 2026 07:45 UTC
Author

Fixes #16807.

Description


ORC COALESCING and MULTITHREADED readers could silently corrupt data when combining compressed files with different compression block sizes. The generated in-memory ORC file inherited the first file's PostScript block size while copying compressed streams from every file.

This change treats compression block size as part of ORC combine compatibility for compressed streams and groups coalescing stripes by compression kind and effective block size. Files with mismatched compressed block sizes are decoded in separate batches. For uncompressed files, the nominal block size is ignored because it does not affect stream encoding, allowing files from different writers to remain combined.

When rebuilding a PostScript, the change also clears the inherited stripe-statistics length because the synthetic file does not contain stripe statistics.

The integration regression test writes three files with 4 KiB, 256 KiB, and 4 KiB compression blocks, verifies their size-sorted order exercises coalescing pre-grouping, and compares complete rows for COALESCING and both ordered and unordered MULTITHREADED readers. Unit tests cover uncompressed block-size normalization and clearing stripe-statistics length. Against the old plugin, the original regression reproduced corruption in both reader modes (CPU string-length sum 640000 versus GPU 117).

Validation:

  • Spark 3.5 / Scala 2.12 package and install

  • Spark 4.0 / Scala 2.13 sql-plugin and tests package

  • Scala 2.12 and Scala 2.13 validate/scalastyle

  • OrcScanSuite: 20 passed

  • test_read_combined_orc_files_with_different_compression_sizes: 3 passed

  • Shim source-selection coverage: PASS
  • Performance testing was not required because files with matching effective compression settings retain the existing grouping path, and uncompressed files with differing nominal block sizes remain combinable. Compressed files with mismatched settings must be split because combining them is not semantically valid; the previous result was corrupt and therefore has no valid performance baseline.

    AI assistance was used to develop and validate this change. The author reviewed the final diff and PR description.

    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

  • 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: 322 lines (+241 / -81) across 4 files Reviewer: firestarman Review duration: 1522m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 322 lines diff across 4 files
    0.42
    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.346
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #17037"
    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: 41.9% (MEDIUM) · Higher = larger blast radius
    41.9%
    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: 16.6% · Safe to merge
    16.6%