[jira] [Commented] (HIVE-15331) Decimal multiplication with high precision/scale often returns NULL

```    [
https://issues.apache.org/jira/browse/HIVE-15331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15712840#comment-15712840
] ```
```
Jason Dere commented on HIVE-15331:
-----------------------------------

While Hive is using similar precision/scale rules as SQL Server for arithmetic
operations (https://msdn.microsoft.com/en-us/library/ms190476.aspx), things
seem to be breaking down once we hit the max precision of 38. Looks like this
sheds a bit of light on how SQL Server handles things in that case:
https://blogs.msdn.microsoft.com/sqlprogrammability/2006/03/29/multiplication-and-division-with-numerics
- basically it gives preference to the integer portion rather than the scale
(Hive does the opposite), and setting a minimum scale of 6.

cc [~xuefuz]

> Decimal multiplication with high precision/scale often returns NULL
> -------------------------------------------------------------------
>
>                 Key: HIVE-15331
>                 URL: https://issues.apache.org/jira/browse/HIVE-15331
>             Project: Hive
>          Issue Type: Bug
>          Components: Types
>            Reporter: Jason Dere
>            Assignee: Jason Dere
>
> {noformat}
> create temporary table dec (a decimal(38,18));
> insert into dec values(100.0);
> hive> select a*a from dec;
> OK
> NULL
> Time taken: 0.165 seconds, Fetched: 1 row(s)
> {noformat}
> Looks like the reason is because the result of decimal(38,18) *
> decimal(38,18) only has 2 digits of precision for integers:
> {noformat}
> hive> set hive.explain.user=false;
> hive> explain select a*a from dec;
> OK
> STAGE DEPENDENCIES:
>   Stage-0 is a root stage
> STAGE PLANS:
>   Stage: Stage-0
>     Fetch Operator
>       limit: -1
>       Processor Tree:
>         TableScan
>           alias: dec
>           Select Operator
>             expressions: (a * a) (type: decimal(38,36))
>             outputColumnNames: _col0
>             ListSink
> Time taken: 0.039 seconds, Fetched: 15 row(s)
> {noformat}

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