fix: [branch-1.1] plan folded UnsafeArrayData array literals natively (#6666) #7449
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
comphead
Which issue does this PR close?
Closes #2717 on
branch-1.1. #2718 changed the cast toArrayData, which turned theClassCastExceptioninto theUNSUPPORTED_CALLerror below. The bug has been present since 0.12.0.Backport of the array literal fix in #6666 to
branch-1.1. Only theliterals.scalalines are taken.(cherry picked from commit 070951d2a77fbaa597056d8de48d29812b10f2e5)
Other release branches:
branch-1.2has the fix from #6666.branch-1.0has the same two.arraycalls (literals.scalalines 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,CometLiteralserializes array literals throughArrayData.array. A constant-folded array literal is anUnsafeArrayData, which has no backing object array, so planning throws: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 isspark.comet.expression.Literal.enabled=false, which turns off native support for every literal.mainfixed this in #6666. That PR bundles the fix with the OneRowRelation change, so this backport takes only theliterals.scalalines.What changes are included in this PR?
literals.scala: read top-level and nested array literals withtoArray[Any](elementType)instead of.array. These are the same two lines #6666 changed in this file.CometArrayExpressionSuite: a regression test that projects flat and nestedsequence(...)literals over a Parquet table and checks the plan runs in Comet. #6666 covers these literals inone_row_relation.sql, which needs its OneRowRelation change, so this test reads from a table instead. It is a Scala test becauseCometSqlFileTestSuiteon this branch always excludesConstantFolding, so a SQL file would never build the folded literal.How are these changes tested?
Run locally on
branch-1.1with-Pspark-4.0on JDK 17:literals.scalachange, the new test fails with theUNSUPPORTED_CALLerror above.CometArrayExpressionSuitepass.spotless:checkpasses.🤖 Generated with Claude Code