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
This is actually two bugs, but are very closely related.
Fully reproducible code snippet
Please include a fully reproducible code snippet or the input sql, dialect, and expected output.
First issue
fromsqlglotimportparse_one, expfromsqlglot.dialectsimportSnowflakefromsqlglot.optimizerimportbuild_scope, find_all_in_scopefromsqlglot.optimizer.qualifyimportqualifyqry=""" with a as ( select '{"from": 12345, "to": 67890}' as json_blob ) -- or ::INTEGER select try_parse_json(json_blob):from::STRING from a"""ast=parse_one(qry, dialect=Snowflake)
q_ast=qualify(ast, dialect=Snowflake)
root=build_scope(q_ast)
forscopeinroot.traverse():
forcolumninset(scope.columns):
print(column)
Produces
ParseError: Invalid expression / Unexpected token. Line 6, Col: 41. select '{"from": 12345, "to": 67890}' as json_blob ) select try_parse_json(json_blob):from::STRING from a
Alternatively:
Invalid JSON path syntax. Unexpected TokenType.L_PAREN at index 1: CAST(from AS TEXT)
Second issue
The other example uses the following query:
ParseError: Invalid expression / Unexpected token. Line6, Col: 42.
select'{"from": 12345, "to": 67890}'as json_blob
)
-- NOTE: The space preceding the `||` is optionalselect try_parse_json(json_blob):from||' test'from a
Will fail with:
Unexpected TokenType.STRING at index 2: from || ' test '
Official Documentation
Please include links to official SQL documentation related to your issue.
The text was updated successfully, but these errors were encountered:
seve-martinez
changed the title
JSON Blob syntax fails when including a typecast or || concat
JSON Blob syntax fails when including a typecast or || concat in Snowflake
Mar 1, 2024
This is actually two bugs, but are very closely related.
Fully reproducible code snippet
Please include a fully reproducible code snippet or the input sql, dialect, and expected output.
First issue
Produces
Alternatively:
Invalid JSON path syntax. Unexpected TokenType.L_PAREN at index 1: CAST(from AS TEXT)
Second issue
The other example uses the following query:
Will fail with:
Unexpected TokenType.STRING at index 2: from || ' test '
Official Documentation
Please include links to official SQL documentation related to your issue.
The text was updated successfully, but these errors were encountered: