[ 
https://issues.apache.org/jira/browse/HIVE-11880?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

WangMeng updated HIVE-11880:
----------------------------
    Description: 
   For UNION ALL , when an union operator is constant(column 'a' such as '0L')  
and it has incompatible type with the corresponding column A(INT type). 
  Query with filter condition on type incompatible column on this UNION ALL  
will cause IndexOutOfBoundsException.

 Such as TPC-H table "orders",in  the fllowing query:
 Type of 'o_custkey' is INT normally,  while  the type of corresponding column 
constant "0" is BIGINT( `0L AS `o_custkey` ). 
 This query (with filter " incompatible column 'o_custkey' ")  will fail  with  
java.lang.IndexOutOfBoundsException : 
{code}
SELECT Count(1)
FROM   (
              SELECT `o_orderkey` ,
                     `o_custkey`
              FROM   `orders`
              UNION ALL
              SELECT `o_orderkey`,
                     0L  AS `o_custkey`
              FROM   `rcfileorders`) `oo`
WHERE  o_custkey<100000 limit 4 ;

{code}

When 
{code}
set hive.ppd.remove.duplicatefilters=true
{code}
 the fllowing query (with filter " incompatible column 'o_custkey' ")  will 
fail  with  java.lang.IndexOutOfBoundsException:
{code}   
 select count(1) from view_orders  where o_custkey<100000
{code}

  was:
   For Hive UNION ALL , when an union column is constant(column a such as '0L') 
 and it has incompatible type with the corresponding column A(INT Type). 
  Query with filter condition on type incompatible column a on this UNION ALL  
will cause IndexOutOfBoundsException.

 Such as TPC-H table "orders", we  create View  by : 
{code}
  CREATE VIEW `view_orders` AS
  SELECT `oo`.`o_orderkey` ,        
                 `oo`.`o_custkey` 
  FROM   (               
                  SELECT    `o_orderkey` , `0L AS `o_custkey`               
                  FROM       `rcfileorders`               
                  UNION ALL               
                  SELECT     `o_orderkey` ,`o_custkey`               
                  FROM      `textfileorders`) `oo`.
{code}
  In VIEW view_orders , type of 'o_custkey' is INT normally, while  the type of 
corresponding column constant "0" is BIGINT( `0L AS `o_custkey` ).

When 
{code}
set hive.ppd.remove.duplicatefilters=true
{code}
 the fllowing query (with filter " incompatible column 'o_custkey' ")  will 
fail  with  java.lang.IndexOutOfBoundsException:
{code}   
 select count(1) from view_orders  where o_custkey<100000
{code}


> filter bug  of UNION ALL when hive.ppd.remove.duplicatefilters=true and 
> filter condition is type incompatible column 
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-11880
>                 URL: https://issues.apache.org/jira/browse/HIVE-11880
>             Project: Hive
>          Issue Type: Bug
>          Components: Logical Optimizer
>    Affects Versions: 1.2.1
>            Reporter: WangMeng
>            Assignee: WangMeng
>         Attachments: HIVE-11880.01.patch
>
>
>    For UNION ALL , when an union operator is constant(column 'a' such as 
> '0L')  and it has incompatible type with the corresponding column A(INT 
> type). 
>   Query with filter condition on type incompatible column on this UNION ALL  
> will cause IndexOutOfBoundsException.
>  Such as TPC-H table "orders",in  the fllowing query:
>  Type of 'o_custkey' is INT normally,  while  the type of corresponding 
> column constant "0" is BIGINT( `0L AS `o_custkey` ). 
>  This query (with filter " incompatible column 'o_custkey' ")  will fail  
> with  java.lang.IndexOutOfBoundsException : 
> {code}
> SELECT Count(1)
> FROM   (
>               SELECT `o_orderkey` ,
>                      `o_custkey`
>               FROM   `orders`
>               UNION ALL
>               SELECT `o_orderkey`,
>                      0L  AS `o_custkey`
>               FROM   `rcfileorders`) `oo`
> WHERE  o_custkey<100000 limit 4 ;
> {code}
> When 
> {code}
> set hive.ppd.remove.duplicatefilters=true
> {code}
>  the fllowing query (with filter " incompatible column 'o_custkey' ")  will 
> fail  with  java.lang.IndexOutOfBoundsException:
> {code}   
>  select count(1) from view_orders  where o_custkey<100000
> {code}



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

Reply via email to