Skip to content
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

Inconsistent handling of invalid literals within in try(...) #10755

Closed
findepi opened this issue Jan 24, 2022 · 1 comment · Fixed by #10720
Closed

Inconsistent handling of invalid literals within in try(...) #10755

findepi opened this issue Jan 24, 2022 · 1 comment · Fixed by #10720
Labels
bug Something isn't working

Comments

@findepi
Copy link
Member

findepi commented Jan 24, 2022

observed

This catches the error

trino> SELECT try(JSON 'x');
 _col0
-------
 NULL

The behavior is even test-covered at

assertQuery("SELECT JSON_FORMAT(TRY(JSON 'INVALID'))", "SELECT NULL");

however, it's not consistently applied to other literals:

trino> SELECT try(DECIMAL '1.2.3');
Query 20220124_091251_00002_v4784 failed: Invalid decimal value '1.2.3'
java.lang.IllegalArgumentException: Invalid decimal value '1.2.3'
	at io.trino.spi.type.Decimals.parse(Decimals.java:91)
	at io.trino.spi.type.Decimals.parse(Decimals.java:78)
	at io.trino.sql.analyzer.ExpressionAnalyzer$Visitor.visitDecimalLiteral(ExpressionAnalyzer.java:1019)
trino> SELECT try(TIMESTAMP 'right now');
Query 20220124_091326_00004_v4784 failed: line 1:12: 'right now' is not a valid timestamp literal
io.trino.spi.TrinoException: line 1:12: 'right now' is not a valid timestamp literal
	at io.trino.sql.analyzer.SemanticExceptions.semanticException(SemanticExceptions.java:48)
	at io.trino.sql.analyzer.ExpressionAnalyzer$Visitor.visitTimestampLiteral(ExpressionAnalyzer.java:1098)
@findepi findepi added the bug Something isn't working label Jan 24, 2022
@findepi
Copy link
Member Author

findepi commented Jan 24, 2022

expected

All literal forms are validated, regardless of try.
try remains to catch "runtime" errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

1 participant