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

Jason Dere commented on HIVE-6012:
----------------------------------

Taking a look at this. Listed below are the numeric operations that changed 
when they were converted to use GenericUDFs. For these operations the return 
type will be reverted back to the Hive-0.12 behavior:

  int / int     -> decimal, used to be double in Hive-0.12
  float + int   -> double, used to be float in Hive-0.12
  float + float -> double, used to be float in Hive-0.12
  float * int   -> double, used to be float in Hive-0.12
  float * float -> double, used to be float in Hive-0.12

  decimal + float  -> double, used to be decimal in Hive-0.12
  decimal + double -> double, used to be decimal in Hive-0.12
  decimal * float  -> double, used to be decimal in Hive-0.12
  decimal * double -> double, used to be decimal in Hive-0.12
  decimal / float  -> double, used to be decimal in Hive-0.12
  decimal / double -> double, used to be decimal in Hive-0.12

Reverting the last 6 operations, involving decimal and float/double inputs, to 
return decimal type is a bit problematic, due to the fact that we would need to 
determine a precision/scale for the result type. The float/double inputs would 
need to be converted to a decimal value and it is not guaranteed that the value 
can be represented by a decimal, if the float/decimal value is too large.  Have 
a couple of options for what to do, if there is any feedback let me know.
  1) Revert the type to return decimal, and come up with some arbitrary 
precision/scale for the result type, such as the system precison/scale of 
38/18. This means a bit more special case code, and a chance that we may not be 
able to represent the float/double portion if the value is larger than the 
precision.
  2) Given the large changes in the decimal type in this current release, make 
the call that it is ok to leave the changes in result type for the numeric 
operations involving decimal inputs, and consider these as part of the changes 
related to decimal types. This is the more SQL compliant behavior. Currently 
leaning toward this approach.


> restore backward compatibility of arithmetic operations
> -------------------------------------------------------
>
>                 Key: HIVE-6012
>                 URL: https://issues.apache.org/jira/browse/HIVE-6012
>             Project: Hive
>          Issue Type: Bug
>          Components: Query Processor
>    Affects Versions: 0.13.0
>            Reporter: Thejas M Nair
>
> HIVE-5356 changed the behavior of some of the arithmetic operations, and the 
> change is not backward compatible, as pointed out in this [jira 
> comment|https://issues.apache.org/jira/browse/HIVE-5356?focusedCommentId=13813398&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13813398]
> {code}
> int / int => decimal
> float / float => double
> float * float => double
> float + float => double
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to