[ 
https://issues.apache.org/jira/browse/HIVE-2693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13552151#comment-13552151
 ] 

Mark Grover commented on HIVE-2693:
-----------------------------------

[~hagleitn], I see what you mean. The reason I had changed the type was to be 
consistent with other methods in the UDF in terms of "scale" of the return 
type, albeit at the cost of losing precision. In any case, given what you found 
in documentation, I agree that it makes sense to retain the type to decimal. 

However, the scale of the return value in floor/ceil/round UDFs for decimal 
type methods seems incorrect to me. We should be not be setting the return 
values back to the original scale.

This seems to lead to inconsistencies in ceil/floor and a bug in round UDF.
For example,
{code}
mysql> select ceil(-0.33) from t;
+-------------+
| ceil(-0.33) |
+-------------+
|           0 |
+-------------+
1 row in set (0.00 sec)
{code}
However, patch 21 gives ceil(-0.33) as 0.00. With the proposed change, the 
result in hive would be consistent in representation with MySQL.

Here is what seems like a bug in round UDF:
In MySQL:
round(1E-99,2)=0.00
But, hive gives
round(1E-99,2)=0E-99
which seems to be the incorrect representation.

The proposed change will make hive give the correct result (consistent with 
MySQL): round(1E-99,2)=0.00

What do you think? If you agree, I can upload the new patch. Please let me 
know. Thanks!
                
> Add DECIMAL data type
> ---------------------
>
>                 Key: HIVE-2693
>                 URL: https://issues.apache.org/jira/browse/HIVE-2693
>             Project: Hive
>          Issue Type: New Feature
>          Components: Query Processor, Types
>    Affects Versions: 0.10.0
>            Reporter: Carl Steinbach
>            Assignee: Prasad Mujumdar
>         Attachments: 2693_7.patch, 2693_8.patch, 2693_fix_all_tests1.patch, 
> HIVE-2693-10.patch, HIVE-2693-11.patch, HIVE-2693-12-SortableSerDe.patch, 
> HIVE-2693-13.patch, HIVE-2693-14.patch, HIVE-2693-15.patch, 
> HIVE-2693-16.patch, HIVE-2693-17.patch, HIVE-2693-18.patch, 
> HIVE-2693-19.patch, HIVE-2693-1.patch.txt, HIVE-2693-20.patch, 
> HIVE-2693-21.patch, HIVE-2693-22.patch, HIVE-2693-all.patch, 
> HIVE-2693.D7683.1.patch, HIVE-2693-fix.patch, HIVE-2693.patch, 
> HIVE-2693-take3.patch, HIVE-2693-take4.patch
>
>
> Add support for the DECIMAL data type. HIVE-2272 (TIMESTAMP) provides a nice 
> template for how to do this.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to