taozhi8833998 / node-sql-parser

Parse simple SQL statements into an abstract syntax tree (AST) with the visited tableList and convert it back to SQL
https://taozhi8833998.github.io/node-sql-parser/
Apache License 2.0
818 stars 181 forks source link

AT TIME ZONE still fails to parse under certain circumstances #2226

Open dannflor opened 2 days ago

dannflor commented 2 days ago

Describe the bug I filed #2201 with a minimum repro, which you were able to fix (thank you!) but AT TIME ZONE is still failing in the way we're using it.

Database Engine PostgreSQL

To Reproduce First off, select start_time AT time zone 'UTC' as start_time from my_table succeeds but select start_time at time zone 'UTC' as start_time from my_table fails. It appears the AT is case sensitive.

Secondly, using a variable instead of a literal fails: select start_time at time zone loc.timezone as start_time from my_table

Here is a more complicated version we would also expect to parse: select date(cast(t.start_time at time zone loc.timezone as timestamptz)) as start_time from my_table t

Expected behavior All three examples should parse as they are valid sql.

Additional context 5.3.4