File tree Expand file tree Collapse file tree 3 files changed +33
-21
lines changed Expand file tree Collapse file tree 3 files changed +33
-21
lines changed Original file line number Diff line number Diff line change @@ -5291,12 +5291,15 @@ impl<'a> Parser<'a> {
5291
5291
Err ( _) => false ,
5292
5292
} ;
5293
5293
5294
- let with_offset_alias =
5294
+ let with_offset_alias = if with_offset {
5295
5295
match self . parse_optional_alias ( keywords:: RESERVED_FOR_COLUMN_ALIAS ) {
5296
5296
Ok ( Some ( alias) ) => Some ( alias) ,
5297
5297
Ok ( None ) => None ,
5298
5298
Err ( e) => return Err ( e) ,
5299
- } ;
5299
+ }
5300
+ } else {
5301
+ None
5302
+ } ;
5300
5303
5301
5304
Ok ( TableFactor :: UNNEST {
5302
5305
alias,
Original file line number Diff line number Diff line change @@ -94,6 +94,34 @@ fn parse_table_identifiers() {
94
94
test_table_ident ( "abc5.GROUP" , vec ! [ Ident :: new( "abc5" ) , Ident :: new( "GROUP" ) ] ) ;
95
95
}
96
96
97
+ #[ test]
98
+ fn parse_join_constraint_unnest_alias ( ) {
99
+ assert_eq ! (
100
+ only(
101
+ bigquery( )
102
+ . verified_only_select( "SELECT * FROM t1 JOIN UNNEST(t1.a) AS f ON c1 = c2" )
103
+ . from
104
+ )
105
+ . joins,
106
+ vec![ Join {
107
+ relation: TableFactor :: UNNEST {
108
+ alias: table_alias( "f" ) ,
109
+ array_expr: Box :: new( Expr :: CompoundIdentifier ( vec![
110
+ Ident :: new( "t1" ) ,
111
+ Ident :: new( "a" )
112
+ ] ) ) ,
113
+ with_offset: false ,
114
+ with_offset_alias: None
115
+ } ,
116
+ join_operator: JoinOperator :: Inner ( JoinConstraint :: On ( Expr :: BinaryOp {
117
+ left: Box :: new( Expr :: Identifier ( "c1" . into( ) ) ) ,
118
+ op: BinaryOperator :: Eq ,
119
+ right: Box :: new( Expr :: Identifier ( "c2" . into( ) ) ) ,
120
+ } ) ) ,
121
+ } ]
122
+ ) ;
123
+ }
124
+
97
125
#[ test]
98
126
fn parse_trailing_comma ( ) {
99
127
for ( sql, canonical) in [
Original file line number Diff line number Diff line change @@ -3683,25 +3683,6 @@ fn parse_unnest() {
3683
3683
joins: vec![ ] ,
3684
3684
} ] ,
3685
3685
) ;
3686
- // 5. WITH OFFSET and WITH OFFSET Alias
3687
- chk (
3688
- true ,
3689
- false ,
3690
- true ,
3691
- & dialects,
3692
- vec ! [ TableWithJoins {
3693
- relation: TableFactor :: UNNEST {
3694
- alias: Some ( TableAlias {
3695
- name: Ident :: new( "numbers" ) ,
3696
- columns: vec![ ] ,
3697
- } ) ,
3698
- array_expr: Box :: new( Expr :: Identifier ( Ident :: new( "expr" ) ) ) ,
3699
- with_offset: false ,
3700
- with_offset_alias: Some ( Ident :: new( "with_offset_alias" ) ) ,
3701
- } ,
3702
- joins: vec![ ] ,
3703
- } ] ,
3704
- ) ;
3705
3686
}
3706
3687
3707
3688
#[ test]
You can’t perform that action at this time.
0 commit comments