diff --git a/pegjs/trino.pegjs b/pegjs/trino.pegjs index 6866193a..bafe3aa8 100644 --- a/pegjs/trino.pegjs +++ b/pegjs/trino.pegjs @@ -3340,7 +3340,7 @@ multiplicative_operator = "*" / "/" / "%" / "||" column_ref_array_index - = c:column_ref __ a:array_index? { + = c:column_ref __ a:array_index_list? { // => column_ref if (a) c.array_index = a return c diff --git a/test/trino.spec.js b/test/trino.spec.js index 3496142e..25c7083b 100644 --- a/test/trino.spec.js +++ b/test/trino.spec.js @@ -84,6 +84,20 @@ describe('trino', () => { `SELECT ddd(split(name, '_')[1]) AS "test" FROM "tableName" WHERE u BETWEEN t('today') AND t('tomorrow') LIMIT 10` ] }, + { + title: 'array index', + sql: [ + 'SELECT a[1] FROM t', + 'SELECT a[1] FROM "t"' + ] + }, + { + title: 'array index list', + sql: [ + 'SELECT a[1][2], a[2] FROM t', + 'SELECT a[1][2], a[2] FROM "t"' + ] + } ] SQL_LIST.forEach(sqlInfo => { const { title, sql } = sqlInfo