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

Ashish Doneriya commented on HIVE-22233:
----------------------------------------

I tested on hive version 1.2.1 and 3.1.2 and I am getting the expected result 
(1)

> Wrong result with vectorized execution when column value is casted to TINYINT
> -----------------------------------------------------------------------------
>
>                 Key: HIVE-22233
>                 URL: https://issues.apache.org/jira/browse/HIVE-22233
>             Project: Hive
>          Issue Type: Bug
>          Components: Vectorization
>    Affects Versions: 2.3.4, 2.3.6, 3.1.1
>            Reporter: Ganesha Shreedhara
>            Assignee: wenjun ma
>            Priority: Major
>
> Casting a column value to TINYINT is giving incorrect result when vectorized 
> mode of the reduce-side GROUP BY query execution is enabled by setting 
> *hive.vectorized.execution.reduce.groupby.enabled* parameter (enabled by 
> default). This issue is only when the sub query has SUM/COUNT aggregation 
> operations in IF condition.  
>  
> *Steps to reproduce:* 
> {code:java}
> create table test(id int);
> insert into test values (1);
> SELECT CAST(col AS TINYINT) col_cast FROM ( SELECT IF(SUM(1) > 0, 1, 0) col 
> FROM test) x;
> {code}
>  
> *Result:*
> {code:java}
> 0{code}
> *Expected result:*
> {code:java}
> 1{code}
>  
> We get the expected result when 
> *hive.vectorized.execution.reduce.groupby.enabled* parameter is disabled. 
> We also get the expected result when we don't CAST or don't have SUM/COUNT 
> aggregation in IF condition.
> The following queries give correct result when 
> hive.vectorized.execution.reduce.groupby.enabled is set.  
> {code:java}
> SELECT CAST(col AS INT) col_cast FROM ( SELECT IF(SUM(1) > 0, 1, 0) col FROM 
> test) x;
> SELECT col FROM ( SELECT IF(SUM(1) > 0, 1, 0) col FROM test) x;
> SELECT CAST(col AS TINYINT) col_cast FROM ( SELECT IF(2 > 1, 1, 0) col FROM 
> test) x;
> SELECT CAST(col AS TINYINT) col_cast FROM ( SELECT IF(true, 1, 0) col FROM 
> test) x;
> {code}
>  
> This issue is only when we use *CAST(col AS TINYINT)* along with *IF(SUM(1) > 
> 0, 1, 0)* or *IF(COUNT(1) > 0, 1, 0)* in sub query. 



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

Reply via email to