You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "gurmukh singh (JIRA)" <ji...@apache.org> on 2016/08/18 02:22:20 UTC

[jira] [Updated] (HIVE-14568) Hive Decimal Returns NULL

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

gurmukh singh updated HIVE-14568:
---------------------------------
    Environment: Centos 6.7, Hadoop 2.7.2,hive 1.0.0,2.0  (was: Centos 6.7, Hadoop 2.7.2)

> Hive Decimal Returns NULL
> -------------------------
>
>                 Key: HIVE-14568
>                 URL: https://issues.apache.org/jira/browse/HIVE-14568
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 1.0.0, 1.2.0
>         Environment: Centos 6.7, Hadoop 2.7.2,hive 1.0.0,2.0
>            Reporter: gurmukh singh
>
> Hi
> I was under the impression that the bug: https://issues.apache.org/jira/browse/HIVE-5022 got fixed. But, I see the same issue in Hive 1.0 and hive 1.2 as well.
> hive> desc mul_table;
> OK
> prc                    	decimal(38,28)
> vol                    	decimal(38,10)
> Time taken: 0.068 seconds, Fetched: 2 row(s)
> hive> select prc, vol, prc*vol as cost from mul_table;
> OK
> 1.2    	200    	NULL
> 1.44   	200    	NULL
> 2.14   	100    	NULL
> 3.004  	50     	NULL
> 1.2    	200    	NULL
> Time taken: 0.048 seconds, Fetched: 5 row(s)
> Rather then returning NULL, it should give error or round off.
> I understand that, I can use Double instead of decimal or can cast it, but still returning "Null" will make many things go unnoticed.
> hive> desc mul_table2;
> OK
> prc                    	double
> vol                    	decimal(14,10)
> Time taken: 0.049 seconds, Fetched: 2 row(s)
> hive> select * from mul_table2;
> OK
> 1.4    	200
> 1.34   	200
> 7.34   	100
> 7454533.354544 	100
> Time taken: 0.028 seconds, Fetched: 4 row(s)
> hive> select prc, vol, prc*vol  as cost from mul_table2;
> OK
> 7.34   	100    	734.0
> 7.34   	1000   	7340.0
> 1.0004 	1000   	1000.4
> 7454533.354544 	100    	7.454533354544E8       <----- Wrong result
> 7454533.354544 	1000   	7.454533354544E9       <----- Wrong result
> Time taken: 0.025 seconds, Fetched: 5 row(s)
> Casting:
> hive> select prc, vol, cast(prc*vol as decimal(38,10)) as cost from mul_table2;
> OK
> 7.34   	100    	734
> 7.34   	1000   	7340
> 1.0004 	1000   	1000.4
> 7454533.354544 	100    	745453335.4544
> 7454533.354544 	1000   	7454533354.544
> Time taken: 0.026 seconds, Fetched: 5 row(s) 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)