[ 
https://issues.apache.org/jira/browse/IMPALA-11202?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Anshula Jain reassigned IMPALA-11202:
-------------------------------------

    Assignee:     (was: Anshula Jain)

> Round functions return types for decimals(X, 0) increase precision by 1
> -----------------------------------------------------------------------
>
>                 Key: IMPALA-11202
>                 URL: https://issues.apache.org/jira/browse/IMPALA-11202
>             Project: IMPALA
>          Issue Type: Improvement
>          Components: Frontend
>            Reporter: Csaba Ringhofer
>            Priority: Major
>
> 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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to