Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-27727

Materialized view query rewrite fails if query has decimal derived aggregate

    XMLWordPrintableJSON

Details

    Description

      create table t1 (a int, b decimal(3,2)) stored as orc TBLPROPERTIES ('transactional'='true');
      
      create materialized view mv1 as
      select a, sum(b), count(b) from t1 group by a;
      
      explain cbo
      select a, avg(b) from t1 group by a;
      

      MV is not used

      CBO PLAN:
      HiveProject(a=[$0], _o__c1=[CAST(/($1, $2)):DECIMAL(7, 6)])
        HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[count($1)])
          HiveTableScan(table=[[default, t1]], table:alias=[t1])
      

      If avg input is not decimal but for example int the query plan is rewritten to use the MV

      Attachments

        Issue Links

          Activity

            People

              kkasa Krisztian Kasa
              kkasa Krisztian Kasa
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: