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

Redundant windows when window function arguments are expressions

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.5.0
    • None
    • None

    Description

      Firstly of all, this issue happens when HepPlanner is used with ProjectToWindowRule.PROJECT rule.

      A query with this pattern:

      select fn(col) over w, fn(expr) over w
      from ...
      

      will generate two "LogicalWindow" even if we have only an identical window frame.

      For example,

      select sum(deptno) over(partition by deptno order by sal) as sum1, 
      sum(deptno + deptno) over(partition by deptno order by sal) as sum2
      from emp
      

      gives:

      LogicalProject($0=[$2], $1=[$4])
        LogicalWindow(window#0=[window(partition {1} order by [0] range between UNBOUNDED PRECEDING and CURRENT ROW aggs [SUM($3)])])
          LogicalProject(SAL=[$0], DEPTNO=[$1], $2=[$2], $3=[+($1, $1)])
            LogicalProject(SAL=[$5], DEPTNO=[$7], $2=[$9])
              LogicalWindow(window#0=[window(partition {7} order by [5] range between UNBOUNDED PRECEDING and CURRENT ROW aggs [SUM($7)])])
                LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            julianhyde Julian Hyde
            seanhychu Sean Hsuan-Yi Chu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Issue deployment