We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
try_cast(parse_json(...))
When using try_cast on the result of a parse_json call, the cast can still fail with an error.
try_cast
parse_json
Reproduction
with example as ( select '42' as json ) select try_cast(json_parse(json) as array(varchar)) from example;
Query 20240508_195937_00029_qrpb2 failed: Cannot cast to array(varchar). Expected a json array, but got 42
From what I can tell, this is due to the optimization "for CAST(JSON_PARSE(...) AS ARRAY/MAP/ROW)" here:
https://github.com/trinodb/trino/blob/master/core/trino-main/src/main/java/io/trino/sql/planner/IrExpressionInterpreter.java#L769
However, the "safeness" of the original Cast has seems to be lost in this process, as the JsonToXXXFunctions always error on failure.
Cast
JsonToXXXFunctions
The text was updated successfully, but these errors were encountered:
I should add this behaviour was introduced in 446. It works as expected in 445 (returns NULL).
NULL
Sorry, something went wrong.
Thanks for the report. I'll look into it.
This is fixed by #21800 and will be in the next release.
martint
No branches or pull requests
When using
try_cast
on the result of aparse_json
call, the cast can still fail with an error.Reproduction
From what I can tell, this is due to the optimization "for CAST(JSON_PARSE(...) AS ARRAY/MAP/ROW)" here:
https://github.com/trinodb/trino/blob/master/core/trino-main/src/main/java/io/trino/sql/planner/IrExpressionInterpreter.java#L769
However, the "safeness" of the original
Cast
has seems to be lost in this process, as theJsonToXXXFunctions
always error on failure.The text was updated successfully, but these errors were encountered: