You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a snippet of the error -- the sqlglot version used is 17.14.2 (latest):
Despite a reserved keyword being used, this is still valid SQL and the SQL will run correctly against the database (in this case, duckdb) so this is a false-positive error.
Additional Details
This is NOT an issue when, either:
The interval column is quoted
The CAST function is used instead of the :: syntax
Note that this also seems to only be the case for this special keyword -- I tried some others, like date, and they have all worked fine.
Here's an MWE to reproduce this error (and show that the other cases work fine):
importsqlglot# 17.14.2SQL_OK_1="""\SELECT CAST(interval AS INTEGER) AS time_intervalFROM staging.tracker"""SQL_OK_2="""\SELECT "interval"::INTEGER AS time_intervalFROM staging.tracker"""SQL_OK_3="""\SELECT date::DATE AS tracker_dateFROM staging.tracker"""SQL_ERROR="""\SELECT interval::INTEGER AS time_intervalFROM staging.tracker"""# All fineprint(sqlglot.parse(SQL_OK_1, read="duckdb"))
print(sqlglot.parse(SQL_OK_2, read="duckdb"))
print(sqlglot.parse(SQL_OK_3, read="duckdb"))
# No likeyprint(sqlglot.parse(SQL_ERROR, read="duckdb"))
The text was updated successfully, but these errors were encountered:
Details (bug)
First off -- I love this library! It's super helpful 😄
What I've found looks like a bug, but it looks like it's because of an unquoted reserved keyword being used in the SQL that's being parsed.
The following SQL results in a
ParseError
after passing it to thesqlglot.parse
function:Here's a snippet of the error -- the sqlglot version used is 17.14.2 (latest):
Despite a reserved keyword being used, this is still valid SQL and the SQL will run correctly against the database (in this case, duckdb) so this is a false-positive error.
Additional Details
This is NOT an issue when, either:
interval
column is quotedCAST
function is used instead of the::
syntaxNote that this also seems to only be the case for this special keyword -- I tried some others, like
date
, and they have all worked fine.Here's an MWE to reproduce this error (and show that the other cases work fine):
The text was updated successfully, but these errors were encountered: