← Back to Pull requests

[SPARK-60871][SQL][4.x] Respect collated result types in variant_get and JSON RETURNING #60391

Closed
unknown closed this pull request without merging on Nov 12, 2026 16:51 UTC
View on GitHub
unknown unknown commented on Nov 12, 2026 16:09 UTC
Author

Backport of #60060 to 4.x

What changes were proposed in this pull request?

1. Goal: variant_get / try_variant_get with a collated target type, and JSON_VALUE / JSON_QUERY / JSON_ARRAY / JSON_OBJECT with a collated RETURNING type, compare using that collation.
2. Problem: The result takes the collation of the arguments, so it gets cast back to UTF8_BINARY before the comparison.

-- status values: 'Open', 'open', 'OPEN', 'closed'
SELECT id FROM t WHERE variant_get(v, '$.status', 'STRING COLLATE UTF8_LCASE') = 'open';
-- Before: 2. Target: 1, 2, 3

3. Solution: These expressions now take the collation of an explicitly collated result type with implicit strength, like a column of that type. Plain STRING is unchanged. Runtime Bloom filters are also skipped for join keys that aren't binary stable, since the filter hashes raw bytes and can drop rows that match under the collation.

Why are the changes needed?

Wrong results.

Does this PR introduce _any_ user-facing change?

Yes. These results now use the declared collation. Mixing one with a string of a different implicit collation, e.g. a plain STRING column, fails with INDETERMINATE_COLLATION_IN_EXPRESSION, same as two columns with different collations. See the migration guide note.

How was this patch tested?

New tests.

Was this patch authored or co-authored using generative AI tooling?


Co-authored-by: Claude Opus 5.5

Diff: 181 lines (+135 / -46) across 2 files Reviewer: uros-b Review duration: 41m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 181 lines diff across 2 files
0.36
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.311
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #60391"
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: 35.6% (MEDIUM) · Higher = larger blast radius
35.6%
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: 14.1% · Safe to merge
14.1%
Repository