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 whitespace handling in numeric cast from varchar #23359

Closed
findepi opened this issue Sep 11, 2024 · 0 comments · Fixed by #23375
Closed

Inconsistent whitespace handling in numeric cast from varchar #23359

findepi opened this issue Sep 11, 2024 · 0 comments · Fixed by #23375
Labels
bug Something isn't working

Comments

@findepi
Copy link
Member

findepi commented Sep 11, 2024

Whitespace is not allowed when casting to integer (or other exact numeric types including bigint, decimal)

trino> SELECT CAST(' 123' AS integer);
Query 20240911_093239_00097_snjt3 failed: Cannot cast ' 123' to INT
trino> SELECT CAST('123 ' AS integer);
Query 20240911_093248_00098_snjt3 failed: Cannot cast '123 ' to INT
trino> SELECT CAST(' 123 ' AS integer);
Query 20240911_093336_00104_snjt3 failed: Cannot cast ' 123 ' to INT

but it's allowed when casting to real, double

trino> SELECT CAST(' 123 ' AS real);
 _col0
-------
 123.0
trino> SELECT CAST(' 123 ' AS double);
 _col0
-------
 123.0
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