You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Sergey Zadoroshnyak (JIRA)" <ji...@apache.org> on 2016/08/29 09:29:20 UTC

[jira] [Commented] (HIVE-14530) Union All query returns incorrect results.

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

Sergey Zadoroshnyak commented on HIVE-14530:
--------------------------------------------

[~liwenhe] [~jcamachorodriguez]

In my opinion, this issue is broken by https://issues.apache.org/jira/browse/HIVE-13639 

By default Cost-based optimization in Hive, which uses the Calcite framework is enabled. (set hive.cbo.enable=true). 

 [~jcamachorodriguez] introduced a new rule HiveUnionPullUpConstantsRule, which was added in relOptRules by CalcitePlanner.

Please take a look at review request: https://reviews.apache.org/r/46974/diff/1#2

If we set hive.cbo.enable=false, the issue is not reproduced. 

[~liwenhe] Please update component -> CBO.

[~jcamachorodriguez] Could you please take a look? 





> Union All query returns incorrect results.
> ------------------------------------------
>
>                 Key: HIVE-14530
>                 URL: https://issues.apache.org/jira/browse/HIVE-14530
>             Project: Hive
>          Issue Type: Bug
>          Components: Query Planning
>    Affects Versions: 2.1.0
>         Environment: Hadoop 2.6
> Hive 2.1
>            Reporter: wenhe li
>            Assignee: Jesus Camacho Rodriguez
>
> create table dw_tmp.l_test1 (id bigint,val string,trans_date string) row format delimited fields terminated by ' ' ;
> create table dw_tmp.l_test2 (id bigint,val string,trans_date string) row format delimited fields terminated by ' ' ;  
> select * from dw_tmp.l_test1;
> 1       table_1      2016-08-11
> select * from dw_tmp.l_test2;
> 2       table_2      2016-08-11
> -- right like this
> select 
>     id,
>     'table_1' ,
>     trans_date
> from dw_tmp.l_test1
> union all
> select 
>     id,
>     val,
>     trans_date
> from dw_tmp.l_test2 ;
> 1       table_1     2016-08-11
> 2       table_2     2016-08-11
> -- incorrect
> select 
>     id,
>     999,
>     'table_1' ,
>     trans_date
> from dw_tmp.l_test1
> union all
> select 
>     id,
>     999,
>     val,
>     trans_date
> from dw_tmp.l_test2 ;
> 1       999     table_1     2016-08-11
> 2       999     table_1     2016-08-11     <-- here is wrong
> -- incorrect
> select 
>     id,
>     999,
>     666,
>     'table_1' ,
>     trans_date
> from dw_tmp.l_test1
> union all
> select 
>     id,
>     999,
>     666,
>     val,
>     trans_date
> from dw_tmp.l_test2 ;
> 1       999     666     table_1 2016-08-11
> 2       999     666     table_1 2016-08-11     <-- here is wrong
> -- right
> select 
>     id,
>     999,
>     'table_1' ,
>     trans_date,
>     '2016-11-11'
> from dw_tmp.l_test1
> union all
> select 
>     id,
>     999,
>     val,
>     trans_date,
>     trans_date
> from dw_tmp.l_test2 ;
> 1       999     table_1 2016-08-11      2016-11-11
> 2       999     table_2 2016-08-11      2016-08-11



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