File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -1715,9 +1715,14 @@ columns_list
17151715 return createList (head, tail);
17161716 }
17171717
1718+ array_index
1719+ = LBRAKE __ n :(literal_numeric / literal_string ) __ RBRAKE {
1720+ return { value: n }
1721+ }
1722+
17181723column_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
17211726 }
17221727 / l :(LBRAKE __ (KW_OFFSET / KW_ORDINAL / KW_SAFE_OFFSET / KW_SAFE_ORDINAL ) __ LPAREN __ (literal_numeric / literal_string ) __ RPAREN __ RBRAKE )+ {
17231728 return l .map (item => ({ name: item[2 ], value: item[6 ] }))
@@ -2448,13 +2453,15 @@ column_ref
24482453 ... getLocationObject (),
24492454 };
24502455 }
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;
24542461 return {
24552462 type: ' column_ref' ,
24562463 table: null ,
2457- column: typeof col === ' string ' ? col : { expr : col },
2464+ column,
24582465 collate: ce && ce[1 ],
24592466 ... getLocationObject ()
24602467 };
Original file line number Diff line number Diff line change @@ -877,6 +877,13 @@ describe('BigQuery', () => {
877877 'SELECT `Customer id` FROM transactions'
878878 ]
879879 } ,
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+ } ,
880887 ]
881888
882889 SQL_LIST . forEach ( sqlInfo => {
You can’t perform that action at this time.
0 commit comments