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

Wrong optimization because window missing constants in digest

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.39.0
    • core

    Description

      Here is a simple case:

      select sum(100) over (partition by deptno order by sal) as s -- window1
      from emp
      union all
      select sum(1000) over(partition by deptno order by sal) as s -- window2
      from emp 

      window1 is different from window2.

      But window digest missing constants, the window2 will be replaced by window1 after optimized.

      LogicalUnion(all=[true])
        LogicalProject($0=[$2])
          LogicalWindow(window#0=[window(partition {1} order by [0] aggs [SUM($2)])]) -- window1 digest
            LogicalProject(SAL=[$5], DEPTNO=[$7])
              LogicalTableScan(table=[[CATALOG, SALES, EMP]])
        LogicalProject($0=[$2])
          LogicalWindow(window#0=[window(partition {1} order by [0] aggs [SUM($2)])]) -- window1 digest
            LogicalProject(SAL=[$5], DEPTNO=[$7])
              LogicalTableScan(table=[[CATALOG, SALES, EMP]]) 

      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: