File tree 2 files changed +20
-6
lines changed 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -1715,9 +1715,14 @@ columns_list
1715
1715
return createList (head, tail);
1716
1716
}
1717
1717
1718
+ array_index
1719
+ = LBRAKE __ n :(literal_numeric / literal_string ) __ RBRAKE {
1720
+ return { value: n }
1721
+ }
1722
+
1718
1723
column_offset_expr_list
1719
- = l :( LBRAKE __ ( literal_numeric / literal_string ) __ RBRAKE ) + {
1720
- return l . map ( item => ({ value : item[ 2 ] }))
1724
+ = l :array_index + {
1725
+ return l
1721
1726
}
1722
1727
/ l :(LBRAKE __ (KW_OFFSET / KW_ORDINAL / KW_SAFE_OFFSET / KW_SAFE_ORDINAL ) __ LPAREN __ (literal_numeric / literal_string ) __ RPAREN __ RBRAKE )+ {
1723
1728
return l .map (item => ({ name: item[2 ], value: item[6 ] }))
@@ -2448,13 +2453,15 @@ column_ref
2448
2453
... getLocationObject (),
2449
2454
};
2450
2455
}
2451
- / col :(quoted_ident_type / column ) ce :(__ collate_expr )? {
2452
- const column = typeof col === ' string' ? col : col .value ;
2453
- columnList .add (` select::null::${ column} ` );
2456
+ / col :(quoted_ident_type / column ) __ cf :array_index * ce :(__ collate_expr )? {
2457
+ const columnName = typeof col === ' string' ? col : col .value ;
2458
+ columnList .add (` select::null::${ columnName} ` );
2459
+ const column = typeof col === ' string' ? { expr: { type: ' default' , value: col }} : { expr: col }
2460
+ if (cf) column .offset = cf;
2454
2461
return {
2455
2462
type: ' column_ref' ,
2456
2463
table: null ,
2457
- column: typeof col === ' string ' ? col : { expr : col },
2464
+ column,
2458
2465
collate: ce && ce[1 ],
2459
2466
... getLocationObject ()
2460
2467
};
Original file line number Diff line number Diff line change @@ -877,6 +877,13 @@ describe('BigQuery', () => {
877
877
'SELECT `Customer id` FROM transactions'
878
878
]
879
879
} ,
880
+ {
881
+ title : 'math operation together with array access' ,
882
+ sql : [
883
+ 'SELECT my_array[0]/100 FROM table1' ,
884
+ 'SELECT my_array[0] / 100 FROM table1'
885
+ ]
886
+ } ,
880
887
]
881
888
882
889
SQL_LIST . forEach ( sqlInfo => {
You can’t perform that action at this time.
0 commit comments