Commit 43826cd
[SPARK-58224][SQL] ASOF JOIN analysis fixes found during FVT review
### What changes were proposed in this pull request?
Product fixes uncovered while landing ASOF JOIN golden-file tests (SPARK-58173):
1. **Non-boolean `ON`** — report `JOIN_CONDITION_IS_NOT_BOOLEAN_TYPE` (`CheckAnalysis`)
2. **Invalid `MATCH_CONDITION` operator errors** — recover SQL operator text (`!=` vs `<>`, `IS [NOT] DISTINCT FROM`) via parse-tree inspection instead of Catalyst pretty names (`AstBuilder`)
3. **Foldable `MATCH_CONDITION` operands** — assign literals, `CURRENT_TIMESTAMP()`, and session variables to join sides by syntactic position (`AsOfJoin.normalizeMatchOperands`)
4. **Subquery resolution** — resolve subqueries in `AsOfJoin` `ON` / `MATCH_CONDITION` like regular `Join` (`Analyzer.ResolveSubquery`, `ValidateSubqueryExpression`)
5. **Struct/array `MATCH_CONDITION` analysis** — reject empty structs; require identical array element types so analysis matches order-expression construction (`ResolveAsOfJoin`)
### Why are the changes needed?
Without these fixes, FVT and integration tests surfaced misleading errors (e.g. `TABLE_OR_VIEW_NOT_FOUND` for unresolved subqueries) or analysis/execution mismatches on array operands.
### Does this PR introduce _any_ user-facing change?
Yes — clearer analysis errors and correct behavior for foldable operands and subqueries in ASOF JOIN.
### How was this patch tested?
- `PlanParserSuite` — invalid `MATCH_CONDITION` operator text
- `AsOfJoinSQLSuite` — foldable operands, subqueries, struct/array operands
```bash
build/sbt -Dscalastyle.skip=true \
"sql/testOnly org.apache.spark.sql.catalyst.parser.PlanParserSuite -- -z asof" \
"sql/testOnly org.apache.spark.sql.AsOfJoinSQLSuite"
```
Stacked PR: [SPARK-58173](#57306) (FVT goldens) builds on this branch.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #57380 from srielau/SPARK-58224.
Authored-by: Serge Rielau <serge@rielau.com>
Signed-off-by: Yicong-Huang <17627829+Yicong-Huang@users.noreply.github.com>1 parent ab513d6 commit 43826cd
9 files changed
Lines changed: 523 additions & 83 deletions
File tree
- sql
- catalyst/src
- main/scala/org/apache/spark/sql/catalyst
- analysis
- parser
- plans/logical
- test/scala/org/apache/spark/sql/catalyst
- parser
- plans/logical
- core/src/test/scala/org/apache/spark/sql
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2633 | 2633 | | |
2634 | 2634 | | |
2635 | 2635 | | |
| 2636 | + | |
| 2637 | + | |
2636 | 2638 | | |
2637 | 2639 | | |
2638 | 2640 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
678 | 678 | | |
679 | 679 | | |
680 | 680 | | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
| |||
Lines changed: 4 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
| |||
147 | 146 | | |
148 | 147 | | |
149 | 148 | | |
150 | | - | |
151 | | - | |
152 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
153 | 152 | | |
154 | 153 | | |
155 | 154 | | |
| |||
158 | 157 | | |
159 | 158 | | |
160 | 159 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | 160 | | |
196 | 161 | | |
197 | 162 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| |||
Lines changed: 63 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2562 | 2562 | | |
2563 | 2563 | | |
2564 | 2564 | | |
2565 | | - | |
| 2565 | + | |
2566 | 2566 | | |
2567 | 2567 | | |
2568 | 2568 | | |
2569 | | - | |
2570 | | - | |
2571 | | - | |
2572 | | - | |
2573 | | - | |
2574 | | - | |
2575 | | - | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
2576 | 2631 | | |
2577 | 2632 | | |
2578 | 2633 | | |
| |||
Lines changed: 120 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2639 | 2639 | | |
2640 | 2640 | | |
2641 | 2641 | | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
2642 | 2725 | | |
2643 | 2726 | | |
2644 | 2727 | | |
2645 | 2728 | | |
2646 | 2729 | | |
2647 | 2730 | | |
| 2731 | + | |
2648 | 2732 | | |
2649 | 2733 | | |
2650 | 2734 | | |
2651 | 2735 | | |
2652 | 2736 | | |
2653 | 2737 | | |
2654 | | - | |
| 2738 | + | |
2655 | 2739 | | |
2656 | 2740 | | |
2657 | 2741 | | |
| |||
2675 | 2759 | | |
2676 | 2760 | | |
2677 | 2761 | | |
2678 | | - | |
2679 | | - | |
| 2762 | + | |
| 2763 | + | |
2680 | 2764 | | |
2681 | 2765 | | |
2682 | 2766 | | |
| |||
2688 | 2772 | | |
2689 | 2773 | | |
2690 | 2774 | | |
2691 | | - | |
| 2775 | + | |
| 2776 | + | |
2692 | 2777 | | |
2693 | 2778 | | |
2694 | | - | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
2695 | 2782 | | |
2696 | 2783 | | |
2697 | 2784 | | |
| |||
2725 | 2812 | | |
2726 | 2813 | | |
2727 | 2814 | | |
2728 | | - | |
2729 | | - | |
2730 | | - | |
2731 | | - | |
2732 | | - | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
2733 | 2824 | | |
2734 | | - | |
| 2825 | + | |
2735 | 2826 | | |
2736 | 2827 | | |
2737 | 2828 | | |
| |||
2844 | 2935 | | |
2845 | 2936 | | |
2846 | 2937 | | |
2847 | | - | |
2848 | | - | |
2849 | | - | |
2850 | | - | |
2851 | | - | |
2852 | | - | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
2853 | 2943 | | |
2854 | 2944 | | |
2855 | 2945 | | |
| |||
2871 | 2961 | | |
2872 | 2962 | | |
2873 | 2963 | | |
2874 | | - | |
2875 | | - | |
2876 | | - | |
2877 | | - | |
2878 | | - | |
2879 | | - | |
2880 | | - | |
2881 | | - | |
2882 | | - | |
2883 | | - | |
2884 | | - | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
2885 | 2977 | | |
2886 | 2978 | | |
2887 | 2979 | | |
| |||
0 commit comments