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

Xuefu Zhang updated HIVE-5022:
------------------------------

       Resolution: Fixed
    Fix Version/s: 0.13.0
           Status: Resolved  (was: Patch Available)

This is fixed via HIVE-3976 and its related tasks (HIVE-5356, HIVE-5866, etc.). 
Now the output:
{code}
hive> select (cast (4.53 as decimal) / cast(25.86 as decimal)) * cast(0.087 as 
decimal) from decimal_udf limit 1;
OK
0
hive> select (cast (4.53 as decimal(3,2)) / cast(25.86 as decimal(4,2))) * 
cast(0.087 as decimal(3,3)) from decimal_udf limit 1;
OK
0.015240138
hive> select cast (4.53 as decimal) / cast(25.86 as decimal) * cast(0.087 as 
decimal) from decimal_udf limit 1;  
OK
0
hive> select cast (4.53 as decimal(3,2)) / cast(25.86 as decimal(4,2)) * 
cast(0.087 as decimal(3,3)) from decimal_udf limit 1;
OK
0.015240138
{code}

> Decimal Arithmetic generates NULL value
> ---------------------------------------
>
>                 Key: HIVE-5022
>                 URL: https://issues.apache.org/jira/browse/HIVE-5022
>             Project: Hive
>          Issue Type: Bug
>          Components: Types
>    Affects Versions: 0.11.0
>         Environment: Hortonworks 1.3 running Hive 0.11.0.1.3.0.0-107
>            Reporter: Kevin Soo Hoo
>            Assignee: Xuefu Zhang
>             Fix For: 0.13.0
>
>         Attachments: HIVE-5022.1.patch.txt, HIVE-5022.2.patch.txt, 
> HIVE-5022.3.patch.txt
>
>
> When a decimal division is the first operation, the quotient cannot be 
> multiplied in a subsequent calculation. Instead, a NULL is returned. 
> The following yield NULL results:
> select (cast (4.53 as decimal) / cast(25.86 as decimal)) * cast(0.087 as 
> decimal) from <tablename> limit 1;
> select cast (4.53 as decimal) / cast(25.86 as decimal) * cast(0.087 as 
> decimal) from <tablename> limit 1;
> If we move the multiplication operation to be first, then it will 
> successfully calculate the result.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to