@@ -580,24 +580,63 @@ fn get_newline_reserved_token<'a>(
580
580
last_reserved_token : Option < Token < ' a > > ,
581
581
) -> impl FnMut ( & ' a str ) -> IResult < & ' a str , Token < ' a > > {
582
582
move |input : & ' a str | {
583
- let uc_input = get_uc_words ( input, 3 ) ;
584
- let result : IResult < & str , & str > = alt ( (
585
- terminated ( tag ( "AND" ) , end_of_word ) ,
586
- terminated ( tag ( "CROSS APPLY" ) , end_of_word ) ,
587
- terminated ( tag ( "CROSS JOIN" ) , end_of_word ) ,
588
- terminated ( tag ( "ELSE" ) , end_of_word ) ,
589
- terminated ( tag ( "INNER JOIN" ) , end_of_word ) ,
583
+ let uc_input: String = get_uc_words ( input, 3 ) ;
584
+
585
+ // We have to break up the alternatives into multiple subsets
586
+ // to avoid exceeding the alt() 21 element limit.
587
+
588
+ // Standard SQL joins
589
+ let standard_joins = alt ( (
590
590
terminated ( tag ( "JOIN" ) , end_of_word) ,
591
+ terminated ( tag ( "INNER JOIN" ) , end_of_word) ,
591
592
terminated ( tag ( "LEFT JOIN" ) , end_of_word) ,
592
- terminated ( tag ( "LEFT OUTER JOIN" ) , end_of_word) ,
593
- terminated ( tag ( "OR" ) , end_of_word) ,
594
- terminated ( tag ( "OUTER APPLY" ) , end_of_word) ,
595
- terminated ( tag ( "OUTER JOIN" ) , end_of_word) ,
596
593
terminated ( tag ( "RIGHT JOIN" ) , end_of_word) ,
594
+ terminated ( tag ( "FULL JOIN" ) , end_of_word) ,
595
+ terminated ( tag ( "CROSS JOIN" ) , end_of_word) ,
596
+ terminated ( tag ( "LEFT OUTER JOIN" ) , end_of_word) ,
597
597
terminated ( tag ( "RIGHT OUTER JOIN" ) , end_of_word) ,
598
- terminated ( tag ( "WHEN" ) , end_of_word) ,
598
+ terminated ( tag ( "FULL OUTER JOIN" ) , end_of_word) ,
599
+ ) ) ;
600
+
601
+ // Warehouse-specific ANY/SEMI/ANTI joins
602
+ let specific_joins = alt ( (
603
+ terminated ( tag ( "INNER ANY JOIN" ) , end_of_word) ,
604
+ terminated ( tag ( "LEFT ANY JOIN" ) , end_of_word) ,
605
+ terminated ( tag ( "RIGHT ANY JOIN" ) , end_of_word) ,
606
+ terminated ( tag ( "ANY JOIN" ) , end_of_word) ,
607
+ terminated ( tag ( "SEMI JOIN" ) , end_of_word) ,
608
+ terminated ( tag ( "LEFT SEMI JOIN" ) , end_of_word) ,
609
+ terminated ( tag ( "RIGHT SEMI JOIN" ) , end_of_word) ,
610
+ terminated ( tag ( "LEFT ANTI JOIN" ) , end_of_word) ,
611
+ terminated ( tag ( "RIGHT ANTI JOIN" ) , end_of_word) ,
612
+ ) ) ;
613
+
614
+ // Special joins and GLOBAL variants
615
+ let special_joins = alt ( (
616
+ terminated ( tag ( "ASOF JOIN" ) , end_of_word) ,
617
+ terminated ( tag ( "LEFT ASOF JOIN" ) , end_of_word) ,
618
+ terminated ( tag ( "PASTE JOIN" ) , end_of_word) ,
619
+ terminated ( tag ( "GLOBAL INNER JOIN" ) , end_of_word) ,
620
+ terminated ( tag ( "GLOBAL LEFT JOIN" ) , end_of_word) ,
621
+ terminated ( tag ( "GLOBAL RIGHT JOIN" ) , end_of_word) ,
622
+ terminated ( tag ( "GLOBAL FULL JOIN" ) , end_of_word) ,
623
+ ) ) ;
624
+
625
+ // Legacy and logical operators
626
+ let operators = alt ( (
627
+ terminated ( tag ( "CROSS APPLY" ) , end_of_word) ,
628
+ terminated ( tag ( "OUTER APPLY" ) , end_of_word) ,
629
+ terminated ( tag ( "AND" ) , end_of_word) ,
630
+ terminated ( tag ( "OR" ) , end_of_word) ,
599
631
terminated ( tag ( "XOR" ) , end_of_word) ,
600
- ) ) ( & uc_input) ;
632
+ terminated ( tag ( "WHEN" ) , end_of_word) ,
633
+ terminated ( tag ( "ELSE" ) , end_of_word) ,
634
+ ) ) ;
635
+
636
+ // Combine all parsers
637
+ let result: IResult < & str , & str > =
638
+ alt ( ( standard_joins, specific_joins, special_joins, operators) ) ( & uc_input) ;
639
+
601
640
if let Ok ( ( _, token) ) = result {
602
641
let final_word = token. split ( ' ' ) . last ( ) . unwrap ( ) ;
603
642
let input_end_pos =
0 commit comments