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

Jason Dere commented on HIVE-3976:
----------------------------------

One note about propagating precision/scale throughout the expressions, 
especially if we want to have them available through jdbc/odbc. All of the 
add/sub/mult/div operations are implemented as old-style UDFs, which is a bit 
problematic.  The old-style UDFs use reflection to determine the return type 
TypeInfos/ObjectInspectors, based on the return type of the evaluate() method 
chosen for the expression. The way this is being done, we cannot customize the 
precision/scale of the TypeInfo representing the result - the resulting 
TypeInfo would just be the default decimal type with no parameters, and 
whatever default precision/scale information that comes with that type. So if 
you want the type metadata to have the correctly set precision/scale, all of 
the arithmetic operators would need to be redone as GenericUDFs, which allow 
you to customize the return type ObjectInspector during the initialize() 
method.  I had to do the same thing with a few string UDFs to get the varchar 
length reported back correctly in the TypeInfos.
                
> Support specifying scale and precision with Hive decimal type
> -------------------------------------------------------------
>
>                 Key: HIVE-3976
>                 URL: https://issues.apache.org/jira/browse/HIVE-3976
>             Project: Hive
>          Issue Type: Improvement
>          Components: Query Processor, Types
>            Reporter: Mark Grover
>            Assignee: Xuefu Zhang
>         Attachments: remove_prec_scale.diff
>
>
> HIVE-2693 introduced support for Decimal datatype in Hive. However, the 
> current implementation has unlimited precision and provides no way to specify 
> precision and scale when creating the table.
> For example, MySQL allows users to specify scale and precision of the decimal 
> datatype when creating the table:
> {code}
> CREATE TABLE numbers (a DECIMAL(20,2));
> {code}
> Hive should support something similar too.

--
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