[SPARK-60282][SQL] Fix hidden USING columns from join inputs in ASOF JOIN and single-pass JOIN #59591
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 313 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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
Diff Size
diff_size
0.344
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #59591"
general
weight: 0.35
mihailoale-db
What changes were proposed in this pull request?
Two fixes for hidden
USINGcolumns (liked.kafterr LEFT JOIN d USING (k)), one in each analyzer:- Fixed-point: an ASOF JOIN with
USINGnow passes up the hidden columns of its inputs. Added one shared helper for regularUSINGand ASOF one ->NaturalAndUsingJoinResolution.buildUsingJoinProject.- Single-pass: when a join merges the ID mappings of its two sides, it now also keeps the IDs of hidden columns. Before, if a copy of the same table was on the other side, the merged mapping sent
d.kto the copy'sk. Anything that mapsd.kagain then read the wrong column: an ASOF JOINMATCH_CONDITION, ord..### Why are the changes needed?
Each bug makes dual-run fail. In single-pass, they also fail the query at run time or return wrong rows.
Before: fixed-point fails with
UNRESOLVED_COLUMNford.k. After:(10, 1), (20, 2), (30, NULL).Before: single-pass plans
AsOfJoin (x.k >= x.k)and the query fails withINTERNAL_ERROR_ATTRIBUTE_NOT_FOUND. After:(1), (2).Before: single-pass returns
1, 1, 1(the copy'sk). After:1, 2, NULL.### Does this PR introduce _any_ user-facing change?
Yes. The queries above now return the right rows instead of failing or returning wrong ones.
### How was this patch tested?
New queries FVT-ASOF-2-043 to 052 in
join-asof-semantics.sql, and two queries inusing-join.sql. Tests run both analyzers and compare their plans. Without the fixed-point fix, 043 to 045 and 047 to 049 fail. Without the single-pass fix inAsOfJoinResolver, 046, 047 and 050 fail. Without it inJoinResolver, 051, 052 and thent2.query inusing-join.sqlfail.### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code