Stamatis Zampetakis created HIVE-28829:
------------------------------------------

             Summary: Remove redundant aggregate operator from query plan
                 Key: HIVE-28829
                 URL: https://issues.apache.org/jira/browse/HIVE-28829
             Project: Hive
          Issue Type: Improvement
          Components: CBO
            Reporter: Stamatis Zampetakis
            Assignee: Stamatis Zampetakis


Some queries contain redundant aggregate operators in the query plan. One such 
example is shown below. 
{code:sql}
create table t1 (a1 int, b1 string);

explain cbo
select b1 from t1 where a1 = 1
union
select b1 from t1 where a1 = 2
union
select b1 from t1 where 1 = 0;
{code}

{noformat}
HiveAggregate(group=[{0}])
  HiveProject(b1=[$0])
    HiveAggregate(group=[{0}])
      HiveProject(b1=[$0])
        HiveUnion(all=[true])
          HiveProject(b1=[$1])
            HiveFilter(condition=[=($0, 1)])
              HiveTableScan(table=[[default, t1]], table:alias=[t1])
          HiveProject(b1=[$1])
            HiveFilter(condition=[=($0, 2)])
              HiveTableScan(table=[[default, t1]], table:alias=[t1])
{noformat}
It's pretty obvious that the top {{HiveAggregate}} and {{HiveProject}} 
operators are completely redundant and can be removed.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to