nene / sql-parser-cst

Parses SQL into Concrete Syntax Tree (CST)
GNU General Public License v2.0
115 stars 7 forks source link

Unexpected "UNNEST" in BigQuery parser #35

Closed imathews closed 1 year ago

imathews commented 1 year ago

First, many thanks for developing this library!

I'm running into an issue with the BigQuery parser where it seems the UNNEST operator is not recognized. As a trivial example, the query:

SELECT a FROM b
WHERE a IN UNNEST(['foo'])

throws an error:

Syntax Error: Unexpected "UNNEST"
Was expecting to see: "!", "$", "(", "-", ":", "?", "@", "@@", "ARRAY", "B", "BIGNUMERIC", "BR", "CASE", "CAST", "COLLATE", "CURRENT_DATE", "CURRENT_DATETIME", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "DATE", "DATETIME", "EXISTS", "EXTRACT", "FALSE", "IF", "INTERVAL", "JSON", "LEFT", "LOCALTIME", "LOCALTIMESTAMP", "NULL", "NUMERIC", "RB", "RIGHT", "SAFE_CAST", "STRUCT", "TIME", "TIMESTAMP", "TRUE", "X", "[", "~", identifier, number, or string
--> undefined:2:12
  |
2 | WHERE a IN UNNEST(['foo'])
  |            ^

FWIW, this statement is parsed correctly by the SQLite parser.

nene commented 1 year ago

Thanks for reporting. I'll see what can be done.

nene commented 1 year ago

This is now fixed in 0.16.1 release.

imathews commented 1 year ago

Thank you!