-
Notifications
You must be signed in to change notification settings - Fork 778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to parse SQL (postgres) with commented out semicolon #4762
Comments
Also seeing a ton of log messages like this: INFO:sqlglot:Applying array index offset (1) Not sure where it's coming from or if it's relevant |
Hey @dbittenbender, Regarding the comments, this is expected and is happening for the following reasons:
As far as the array indexes are concerned, SQLGlot has logic to canonicalize array indexes between dialects (some are 0-based while others are 1-based etc), but I'd expect to see these during transpilation. Does this lead to incorrect roundtrips in Postgres? Would you be able to find a repro? |
Sorry for the delay in response. I was away. Thanks for your help! I will skip the Semicolon types. For the array indexes, it's not causing any problems that I am aware of, I just never saw that many in the logs before so i wasn't sure if it was related. |
The above SQL is a simplified example as I can't post client code. However, it fails the same way.
I am using read dialect of postgres.
I am first calling
parse(sql_stmt, read=dialect)
with the entire statement expecting to get all of the statements returned as a List. That returns 3 sub-statements: TruncateTable, Insert, and Semicolon. The first 2 are correct. However, the entire 3rd statement (Semicolon) is the commented out lines at the bottom of the full sql statement.Then I try to parse each one of the sub-statements:
ast = parse_one(sql_stmt, read=dialect)
. When I get to the 3rd statement (Semicolon), it fails with:ParseError("No expression was parsed from '/* vacuum after */ /* VACUUM VERBOSE */ /* ANALYZE table1 */ /* ; */'")
It seems like when it parses the end of the file, it get's thrown off by the commented out semicolon.
The text was updated successfully, but these errors were encountered: