← Back to Pull requests

GH-3934: Encrypt DataPageV2 repetition and definition levels together with the values #3935

Open
unknown opened this pull request with 290 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 06, 2026 01:40 UTC
Author

Rationale for this change


Parquet-java is the only implementation that encrypts only the values of a DataPageV2 page and leaves the repetition and definition levels in plaintext. Arrow C++ (and PyArrow), arrow-rs, arrow-go, Polars and Velox all encrypt the whole page body (levels and values) as one module, and DuckDB reads it that way. The spec text is ambiguous for DataPageV2 (see apache/parquet-format#636), so the two layouts cannot read each other's files.

What changes are included in this PR?


  • Writers (ColumnChunkPageWriteStore, ParquetFileWriter, ParquetRewriter) encrypt the levels and the values of a DataPageV2 page as one module.

  • A new ParquetFileWriter.writeDataPageV2 overload takes a page body encryptor. The four overloads that take only a page header encryptor are deprecated, because they leave the levels in plaintext.

  • Readers read both layouts. The reader tells them apart from the module length prefixes. If a page fits both layouts, the reader uses created_by: parquet-java before 1.19.0 wrote plaintext levels, and every other writer uses one module.

  • The old read path is kept only for backward compatibility.

  • Are these changes tested?


    Yes. The tests read fixtures written by Arrow (pyarrow 24.0.0), by parquet-java before this change, and hand-built pages that fit both layouts, with GCM and CTR, heap and direct buffers. They check the bytes that the writer and the rewriter produce with an independent decoder, round-trip files with several row groups and page filtering, and check tamper detection through the GCM tag and the CRC.

    Are there any user-facing changes?


    Yes. This is a breaking change for readers.
    Parquet-java 1.18 and earlier cannot read DataPageV2 pages of encrypted columns with levels that 1.19.0 writes. With AES_GCM_V1 the read fails. With AES_GCM_CTR_V1 the levels are decoded incorrectly without an error. Other implementations can read these files. 1.19.0 still reads files written by earlier versions.
    The ParquetRewriter does not read encrypted input, so it cannot convert old encrypted files. To convert them, read them with 1.19.0 and write them again.
    Closes #3934

    This pr was written with the assistance of Claude Opus 5.5 ~and I haven't fully finished my review which is why I'm leaving this as a draft.~

    Diff: 290 lines (+217 / -73) across 3 files Reviewer: RussellSpitzer Review duration: 36119m
    All Vouch review confidence checks passed
    Residual risk 0.36 = Change Risk (0.63) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.63 · 290 lines diff across 3 files
    0.63
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.339
    Sensitive Paths sensitive_paths
    0.063
    Real PR Conversation Timeline
    1 comments
    "Review active on #3935"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 43.0% reviewed sensitive_module
    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: 63% (MEDIUM) · Higher = larger blast radius
    63%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 36.0% · Moderate risk
    36.0%