mahesh kumar behera created HIVE-24373:
------------------------------------------

             Summary: Wrong predicate is pushed down for view with constant 
value projection.
                 Key: HIVE-24373
                 URL: https://issues.apache.org/jira/browse/HIVE-24373
             Project: Hive
          Issue Type: Bug
            Reporter: mahesh kumar behera
            Assignee: mahesh kumar behera


For below query the predicate pushed down for one of the table scan is not 
proper.

 
{code:java}
set hive.explain.user=false;
set hive.cbo.enable=false;
set hive.optimize.ppd=true;DROP TABLE arc;

CREATE table arc(`dt_from` string, `dt_to` string);
CREATE table loc1(`dt_from` string, `dt_to` string);

CREATE
 VIEW view AS
     SELECT
        '9999' as DT_FROM,
        uuid() as DT_TO
     FROM
       loc1
 UNION ALL
     SELECT
        dt_from as DT_FROM,
        uuid() as DT_TO
     FROM
       arc;

EXPLAIN
    SELECT
      dt_from, dt_to
    FROM
      view
    WHERE
      '2020'  between dt_from and dt_to;


{code}
 

For table loc1,  DT_FROM is projected as '9999' so the predicate "predicate: 
'2020' BETWEEN '9999' AND _col1 (type: boolean)" is proper. But for table arc, 
the column is projected so the predicate should be "predicate: '2020' BETWEEN 
_col0 (type: boolean) AND _col1 (type: boolean)".

This is because the predicates are stored in a map for each expression. Here 
the expression is "_col0". When the predicate is pushed down the union, the 
same predicate is used for creating the filter expression. Later when constant 
replacement is done, the first filter is overwriting the second one.

So we should create a clone (as done at other places) before using the cached 
predicate for filter. This way the overwrite can be avoided.   

 



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

Reply via email to