Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
ghx-label-7
Description
select typeof(ceil(cast(1 as decimal(1, 0))));
result: DECIMAL(2,0)
select typeof(ceil(cast(1 as decimal(38, 0))));
ERROR: AnalysisException: No matching function with signature: typeof(INVALID_TYPE).
Meanwhile precision is not increased if it was non-0:
select typeof(ceil(cast(1 as decimal(38, 1))));
result: DECIMAL(38,0)
select typeof(ceil(cast(1 as decimal(38, 37))));
result: DECIMAL(2,0)
Hive works the same way as Impala.
Generally ceil/floor/round is NOOP for integer types (and decimals with scale 0)
Note that I don't know how other databases handle this, e.g. https://docs.microsoft.com/en-us/sql/t-sql/functions/round-transact-sql?view=sql-server-ver15 says
Expression result Return type
decimal and numeric category (p, s) decimal(p, s)
which looks very different than the way we work.