You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/02/12 00:39:00 UTC

[jira] [Work logged] (HIVE-22877) Wrong decimal boundary for casting to Decimal64

     [ https://issues.apache.org/jira/browse/HIVE-22877?focusedWorklogId=385579&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-385579 ]

ASF GitHub Bot logged work on HIVE-22877:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/Feb/20 00:38
            Start Date: 12/Feb/20 00:38
    Worklog Time Spent: 10m 
      Work Description: mustafaiman commented on pull request #905: HIVE-22877: Wrong decimal boundary for casting to Decimal64
URL: https://github.com/apache/hive/pull/905
 
 
   During vectorization, decimal fields that are obtained via generic udfs are cast to Decimal64 in some circumstances. For decimal to decimal64 cast, hive compares the source column's `scale + precision` to 18(maximum number of digits that can be represented by a long). A decimal can fit in a long as long as its `scale` is smaller than or equal to 18. Precision is irrelevant.
   
   Since vectorized generic udf expression takes precision into account, it computes wrong output column vector: Decimal instead of Decimal64. This in turn causes ClassCastException down the operator chain.
   
   Change-Id: I100cb3fbbc10fb71e8a7a8cd33f5788018388ddb
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 385579)
    Remaining Estimate: 0h
            Time Spent: 10m

> Wrong decimal boundary for casting to Decimal64
> -----------------------------------------------
>
>                 Key: HIVE-22877
>                 URL: https://issues.apache.org/jira/browse/HIVE-22877
>             Project: Hive
>          Issue Type: Bug
>          Components: Vectorization
>    Affects Versions: 4.0.0
>            Reporter: Mustafa Iman
>            Assignee: Mustafa Iman
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: HIVE-22877.patch
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> During vectorization, decimal fields that are obtained via generic udfs are cast to Decimal64 in some circumstances. For decimal to decimal64 cast, hive compares the source column's `scale + precision` to 18(maximum number of digits that can be represented by a long). A decimal can fit in a long as long as its `scale` is smaller than or equal to 18. Precision is irrelevant.
> Since vectorized generic udf expression takes precision into account, it computes wrong output column vector: Decimal instead of Decimal64. This in turn causes ClassCastException down the operator chain.
> Below query fails with class cast exception:
>  
> {code:java}
> create table mini_store
> (
>  s_store_sk int,
>  s_store_id string
> )
> row format delimited fields terminated by '\t'
> STORED AS ORC;
> create table mini_sales
> (
>  ss_store_sk int,
>  ss_quantity int,
>  ss_sales_price decimal(7,2)
> )
> row format delimited fields terminated by '\t'
> STORED AS ORC;
> insert into mini_store values (1, 'store');
> insert into mini_sales values (1, 2, 1.2);
> select s_store_id, coalesce(ss_sales_price*ss_quantity,0) sumsales
> from mini_sales, mini_store where ss_store_sk = s_store_sk
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)