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
The left and right side are different datatypes (string and tinyint), so before the comparison can be done it needs to convert one of them to be able to compare.
In the first query it uses the left side type (string) and convert the right side value 1 also to a string.
In the second query it uses the left side type (tinyint) and convert 'a' to a tinyint, which fails.
A workaround is to use explicit casting in your query, e.g.: select cast(1 as string)>'a';
Note that it can be dangerous to compare strings with numbers (or other types such as dates, intervals, etc) especially when casted to string, as the numbers will be left aligned, so '2' suddenly becomes bigger than '10', where when casted to int the value 2 will not be bigger than 10. select '2'>'10';
returns true select 2 > 10;
returns false
It is better to use explicit casting in these cases,to get the correct/desired semantics.
sql>select 'a'>1;
+-------+
| %2 |
+=======+
| true |
+-------+
sql>select 1>'a';
conversion of string 'a' to type bte failed.
The text was updated successfully, but these errors were encountered: