Details
Description
Implicit down casts from a bigger numeric type to a smaller type should throw an error, when a numeric overflow happens.
Example:
CREATE TABLE downcast_test (int_value INT);
– implicit cast to BIGINT and than implicit cast to INT
INSERT INTO TABLE downcast_test SELECT 2147483647 + 1;
– implicit cast from BIGINT to INT
INSERT INTO TABLE downcast_test SELECT 2147483648L;
– implicit cast from DOUBLE to INT
INSERT INTO TABLE downcast_test SELECT 2.147483648E9;
SELECT * FROM downcast_test;
=>
-2147483648 – expected int overflow value
-2147483648 – expected int overflow value
2147483647 – what happend here? cast from DOUBLE to INT results in INT max value
Here you can see another nice bug with cast from DOUBLE to INT, but this is not the issue here.
Reading the following documentation
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types#LanguageManualTypes-AllowedImplicitConversions
implicit down casts from BIGINT and DOUBLE to INT are not allowed. So an exception is expected. But no exception will be thrown, it quite casts the values somehow down to INT