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

The ‘approximate’ field should be considered when computing the digest of AggregateCall

    XMLWordPrintableJSON

    Details

      Description

      In planner optimization, the digest  of Aggregate node contains digest of its AggregateCall, i.e. AggregateCall.toString, but currently the 'approximate' filed of AggregateCall is not considered in toString() method, which may leads to the situation two different relNodes are considered as identical in planner optimizing phase. 

      Here is an example:

      // SQL
      select * from (
        select a, count(distinct b) from T group by a
        union all
        select a, approx_count_distinct(b) from T group by a
      )
      
      // after applying a rule, the plan is
      LogicalSink(name=[_DataStreamTable_1], fields=[a, EXPR$1], __id__=[96])
      +- LogicalProject(a=[$0], EXPR$1=[$1], __id__=[94])
         +- LogicalUnion(all=[true], __id__=[92])
            :- LogicalAggregate(group=[{0}], EXPR$1=[COUNT(DISTINCT $1)], __id__=[89])
            :  +- LogicalTableScan(table=[[default, _DataStreamTable_2]], __id__=[100])
            +- LogicalAggregate(group=[{0}], EXPR$1=[COUNT(DISTINCT $1)], __id__=[89])
               +- LogicalTableScan(table=[[default, _DataStreamTable_2]], __id__=[100])
      

      As showing in the example, after optimizing, these two Aggregates are considered as identical (both with 89 as relNode ID).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                icshuo Shuo Cheng
                Reporter:
                icshuo Shuo Cheng
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 20m
                  1h 20m