← Back to Pull requests

fix: [branch-1.2] decode invalid UTF-8 in nested Parquet BINARY values read as strings (#7106) #7339

Merged
manuzhang merged 6 files (1057 lines) on Oct 30, 2026 18:50 UTC
View on GitHub
manuzhang manuzhang commented on Oct 30, 2026 15:52 UTC
Author

Which issue does this PR close?

Backport of #7106 to branch-1.2. Part of #7032 (the nested values) and #4764.

Rationale for this change

When a Parquet BINARY column without the UTF8 annotation is read as a string, through a read schema or spark.sql.parquet.binaryAsString=true, the native scan converts nested values (struct fields, list elements, map keys and values) in parquet_convert_array. That fell through to Arrow's safe cast, which turns invalid UTF-8 into NULL, so those values silently became NULL where Spark keeps the bytes. branch-1.2 has this bug. See #7106 for the full rationale.

The fix also goes to branch-1.1 in #7340, opened together with this one. Per the backporting guide, #7340 should not merge before this one is ready.

What changes are included in this PR?

The cherry-pick of 621b9ccdb4658ad2671e4e88e5c51da67e3c8fbc from main, with one adaptation:

  • native/core/src/parquet/parquet_support.rs: the import block conflicted because main also imports SparkError there (added after the 1.2 cut by the timestamp-overflow change). The backport only takes the new spark_cast and SparkCastOptions imports and leaves SparkError out, since nothing on this branch uses it.
  • Everything else, including the docs changes to compatibility/index.md and parquet.md, applied cleanly.

    How are these changes tested?

    The tests from #7106: the Rust unit tests in parquet_support.rs, parquet_exec.rs and cast.rs, and the new ParquetReadSuite test "native scan decodes invalid UTF-8 in nested BINARY read as string".

    Locally on this branch:

  • cargo check --all-targets, cargo clippy --all-targets --workspace -- -D warnings and cargo fmt --check in native/ pass.

  • The parquet_support and parquet_exec tests in datafusion-comet (28 tests) and the cast tests in datafusion-comet-spark-expr (111 tests) pass.

  • ./mvnw test -Dtest=none -Dsuites="org.apache.comet.parquet.ParquetReadV1Suite native scan decodes" passes after make core.
  • 🤖 Generated with Claude Code

    Diff: 1057 lines (+1025 / -32) across 6 files Reviewer: andygrove Review duration: 177m
    All Vouch review confidence checks passed
    Residual risk 0.13 = Change Risk (0.50) × (1 − Review Confidence (0.74)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 1057 lines diff across 6 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.53 · 1 substantive comment(s)
    0.53
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    74%
    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.400
    Real PR Conversation Timeline
    3 items
    andygrove andygrove approved these changes on Oct 30, 2026 18:50 UTC
    Approved Reviewer

    Thanks @manuzhang. I compared the changed lines with 621b9ccdb4 and they match the source commit exactly. The docs link into parquet.md resolves on this branch. Approving. Please let the pending Spark SQL jobs finish before merging, and merge this one before #7340.

    andygrove andygrove commented on Oct 30, 2026 18:50 UTC
    Contributor

    Thanks @manuzhang

    Reviewers
    Assignees
    manuzhang manuzhang
    Labels
    risk: low confidence: 74.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: 50.3% (MEDIUM) · Higher = larger blast radius
    50.3%
    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: 74.5% · Lower = rushed or shallow review
    74.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: 12.8% · Safe to merge
    12.8%