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

Incorrect rewriting with materialized views using DISTINCT in aggregate functions

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.13.0
    • Fix Version/s: 1.15.0
    • Component/s: core
    • Labels:
      None

      Description

      I had written a test as follows . It runs to succeed . But , the result seems not right . The “count distinct” aggregation should not be changed to “count”.

      @Test public void testAggregateMaterializationOnCountDistinctQuery1() {
          checkMaterialize(
              "select \"deptno\",  \"empid\" ,\"salary\"\n"
                  + "from \"emps\" group by \"deptno\",  \"empid\",\"salary\"",
              "select \"deptno\", count( distinct \"empid\")" + "from (select \"deptno\",  \"empid\" \n"
                  + "from \"emps\" group by \"deptno\",  \"empid\")  group by \"deptno\"",
              HR_FKUK_MODEL,
              CalciteAssert.checkResultContains(
                  "EnumerableAggregate(group=[{0}], S=[COUNT($1)])\n" +
                      "  EnumerableTableScan(table=[[hr, m0]]"));
        }
      

        Attachments

          Activity

            People

            • Assignee:
              jcamachorodriguez Jesus Camacho Rodriguez
              Reporter:
              chenfeisd@163.com fei.chen
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: