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
Make sure you specify the "read" dialect eg. parse_one(sql, read="spark"): snowflake
Make sure you specify the "write" dialect eg. ast.sql(dialect="duckdb"): snowflake
Check if the issue still exists on main
Fully reproducible code snippet
Please include a fully reproducible code snippet or the input sql, dialect, and expected output.
Snowflake syntax allows an optional WITH token to add a column with a tag, however, the parser doesn't like the WITH token in this position. If the WITH token is removed the parser doesn't know how to parse the TAG syntax for added columns.
This example doesn't understand the WITH token as part of the Add Column query:
fromsqlglotimportparse_onequery=""" ALTER TABLE db_name.schmaName.tblName add column COLUMN_1 varchar not null WITH TAG (key1 = 'value_1');"""parsed=parse_one(query, read='snowflake')
print(repr(parsed))
...
sqlglot.errors.ParseError: Expecting (. Line2, Col: 84.ALTERTABLEdb_name.schmaName.tblNameaddcolumnCOLUMN_1varcharnotnullTAG (key1='value_1');
This example doesn't raise an exception but still doesn't know how to parse the query to add a column with a tag.
fromsqlglotimportparse_onequery=""" ALTER TABLE db_name.schmaName.tblName add column COLUMN_1 varchar not null TAG (key1 = 'value_1');"""parsed=parse_one(query, read='snowflake')
print(repr(parsed))
...
'ALTER TABLE db_name.schmaName.tblName add column COLUMN_1 varchar not null TAG (key1 = 'value_1')'containsunsupportedsyntax. Fallingbacktoparsingasa'Command'.
Command(this=ALTER, expression=TABLEdb_name.schmaName.tblNameaddcolumnCOLUMN_1varcharnotnullTAG (key1='value_1'))
...
Before you file an issue
parse_one(sql, read="spark")
: snowflakeast.sql(dialect="duckdb")
: snowflakeFully reproducible code snippet
Please include a fully reproducible code snippet or the input sql, dialect, and expected output.
Snowflake syntax allows an optional WITH token to add a column with a tag, however, the parser doesn't like the WITH token in this position. If the WITH token is removed the parser doesn't know how to parse the TAG syntax for added columns.
This example doesn't understand the WITH token as part of the Add Column query:
This example doesn't raise an exception but still doesn't know how to parse the query to add a column with a tag.
Official Documentation
Please include links to official SQL documentation related to your issue.
https://docs.snowflake.com/en/sql-reference/sql/alter-table#table-column-actions-tablecolumnaction
The text was updated successfully, but these errors were encountered: