[
https://issues.apache.org/jira/browse/HIVE-14281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15393127#comment-15393127
]
Chaoyu Tang commented on HIVE-14281:
------------------------------------
Thanks [~sershe] for chiming in. I think the issue here might be sightly
different from that in HIVE-13098. For the example in HIVE-13098, select 999999
as decimal(5,0) should ideally throw out an exception since 999999 exceeds the
decimal(5,0) data range. For the decimal multiplication, I think its result
should be implicitly rounded up (or via a configuration?) as long as it is
within the range supported by the specified decimal. Otherwise, the decimal use
with multiplication will be dramatically limited because of the supported
range. For the example in
https://issues.apache.org/jira/browse/HIVE-14281?focusedCommentId=15384793&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15384793,
the result data range is reduced to (-100, 100). Actually Hive cast also
supports the round up in decimal, select cast(999.999 as decimal(5.0)) returns
1000.
> Issue in decimal multiplication
> -------------------------------
>
> Key: HIVE-14281
> URL: https://issues.apache.org/jira/browse/HIVE-14281
> Project: Hive
> Issue Type: Bug
> Components: Types
> Reporter: Chaoyu Tang
> Assignee: Chaoyu Tang
>
> {code}
> CREATE TABLE test (a DECIMAL(38,18), b DECIMAL(38,18));
> INSERT OVERWRITE TABLE test VALUES (20, 20);
> SELECT a*b from test
> {code}
> The returned result is NULL (instead of 400)
> It is because Hive adds the scales from operands and the type for a*b is set
> to decimal (38, 36). Hive could not handle this case properly (e.g. by
> rounding)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)