Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6201

Merge Aggregate node if count distinct column has been deduplicated

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Duplicate
    • None
    • 1.37.0
    • core
    • None

    Description

      distinct column is redundant because count has distinct. 

      select count(distinct x) cnt
      from(
         select distinct sal x from emp
      ) t 

      PlanBefore is

      LogicalAggregate(group=[{}], CNT=[COUNT(DISTINCT $0)])
        LogicalAggregate(group=[{5}])
          LogicalTableScan(table=[[CATALOG, SALES, EMP]])

      PlanAfter should be 

      LogicalAggregate(group=[{}], CNT=[COUNT(DISTINCT $5)])
          LogicalTableScan(table=[[CATALOG, SALES, EMP]])

      But `CoreRules.AGGREGATE_MERGE` not support it, we can improve it.

       

      Attachments

        Issue Links

          Activity

            People

              jiajunbernoulli Jiajun Xie
              jiajunbernoulli Jiajun Xie
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: