← Back to Pull requests

fix: [branch-1.1] plan folded UnsafeArrayData array literals natively (#6666) #7449

Open
unknown opened this pull request with 300 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 03, 2026 03:47 UTC
Author

Which issue does this PR close?

Closes #2717 on branch-1.1. #2718 changed the cast to ArrayData, which turned the ClassCastException into the UNSUPPORTED_CALL error below. The bug has been present since 0.12.0.

Backport of the array literal fix in #6666 to branch-1.1. Only the literals.scala lines are taken.

(cherry picked from commit 070951d2a77fbaa597056d8de48d29812b10f2e5)

Other release branches:

  • branch-1.2 has the fix from #6666.

  • branch-1.0 has the same two .array calls (literals.scala lines 103 and 211), so it fails the same way. I can open a backport there if 1.0 is still taking patch releases.
  • Rationale for this change

    On branch-1.1, CometLiteral serializes array literals through ArrayData.array. A constant-folded array literal is an UnsafeArrayData, which has no backing object array, so planning throws:

    [UNSUPPORTED_CALL.WITHOUT_SUGGESTION] Cannot call the method "array" of the class "org.apache.spark.sql.catalyst.expressions.UnsafeArrayData"
    

    The query then fails instead of falling back. sequence(1, 5) is one way to produce such a literal. The only workaround on 1.1.0 is spark.comet.expression.Literal.enabled=false, which turns off native support for every literal.

    main fixed this in #6666. That PR bundles the fix with the OneRowRelation change, so this backport takes only the literals.scala lines.

    What changes are included in this PR?

  • literals.scala: read top-level and nested array literals with toArray[Any](elementType) instead of .array. These are the same two lines #6666 changed in this file.

  • CometArrayExpressionSuite: a regression test that projects flat and nested sequence(...) literals over a Parquet table and checks the plan runs in Comet. #6666 covers these literals in one_row_relation.sql, which needs its OneRowRelation change, so this test reads from a table instead. It is a Scala test because CometSqlFileTestSuite on this branch always excludes ConstantFolding, so a SQL file would never build the folded literal.
  • How are these changes tested?

    Run locally on branch-1.1 with -Pspark-4.0 on JDK 17:

  • Without the literals.scala change, the new test fails with the UNSUPPORTED_CALL error above.

  • With it, all 74 tests in CometArrayExpressionSuite pass.

  • spotless:check passes.
  • 🤖 Generated with Claude Code

    Diff: 300 lines (+225 / -75) across 3 files Reviewer: comphead Review duration: 2638m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.40) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 300 lines diff across 3 files
    0.40
    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.341
    Real PR Conversation Timeline
    1 comments
    "Review active on #7449"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 40.1% (MEDIUM) · Higher = larger blast radius
    40.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: 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: 22.9% · Safe to merge
    22.9%