Simhadri G created HIVE-26424: --------------------------------- Summary: When decimal type has overflowed the specified precision it must throw an error/warning instead of succeeding with NULL entries Key: HIVE-26424 URL: https://issues.apache.org/jira/browse/HIVE-26424 Project: Hive Issue Type: Bug Reporter: Simhadri G
When the decimal type has overflowed the specified precision, it results in null entries as seen below: {code:java} 0: jdbc:hive2://localhost:10001/> select cast(48932.19 AS DECIMAL(6,6)); +-------+ | _c0 | +-------+ | NULL | +-------+ 1 row selected (0.178 seconds){code} This can be a significant issue when inserting a large amount of data from one table to another. This can result in entire columns having NULL entries, as seen below {code:java} 0: jdbc:hive2://localhost:10001/> select * from t2; +-------------------+ | t2.num | +-------------------+ | 28367.8100000000 | | 49632.1900000000 | | NULL | | 28367.8100000000 | | 49632.1900000000 | | NULL | +-------------------+ 6 rows selected (0.202 seconds) 0: jdbc:hive2://localhost:10001/> create table t3(num decimal(20,10)); 0: jdbc:hive2://localhost:10001/> insert into t3 select cast(t2.num as decimal(5,2)) from t2; 12 rows affected (40.97 seconds) 0: jdbc:hive2://localhost:10001/> select * from t3; +---------+ | t3.num | +---------+ | NULL | | NULL | | NULL | | NULL | | NULL | | NULL | +---------+ 6 rows selected (0.205 seconds){code} I think it would be better to throw an error as below instead of succeeding. Similar to Mysql. {code:java} ERROR : Out of range value for column 'cast(num as decimal(5,2))' {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)