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
798 stars 180 forks source link

Trino dialect - Parser providing incorrect error information #1935

Closed npmccauslin closed 4 months ago

npmccauslin commented 4 months ago

Describe the bug

1 Using trino dialect, this query has error positioning issues:

FROM table
WHERE u BETWEEN * - * - * - * - * t('today')
LIMIT 10

I don't think the ----* is valid trino syntax but it doesn't error, instead it reports an error at the t('today') part, which I think is valid.

2 This query also falsely reports error on the brackets:

SELECT length(split(name, '_')[1]) as test
FROM tableName
WHERE u BETWEEN t('today') and t('tomorrow')
LIMIT 10

Database Engine Trino

To Reproduce -the SQL that be parsed:

FROM table
WHERE u BETWEEN * - * - * - * - * t('today')
LIMIT 10

and

SELECT length(split(name, '_')[1]) as test
FROM tableName
WHERE u BETWEEN t('today') and t('tomorrow')
LIMIT 10

-the node-sql-parser version: v5.2.0 -the node version: v18.20.2

Expected behavior I would expect the error to report on the first * (and the message to be that it isn't valid) rather than the t in t('today').

Screenshots Current errors for above queries: Screenshot 2024-06-05 at 11 22 36 AM