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

Calcite incorrectly permutes columns of OVER query

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

      To reproduce this issue, add ProjectToWindowRule to the Hep Planner.

      Then, a query below would fail with an Assertion Error (type mis-match)

      select count(*) over(partition by empno order by sal) as count1,
            count(*) over(partition by deptno order by sal) as count2, 
            sum(deptno)  over(partition by empno order by sal) as sum1
      from emp
      

      However, if the second and third columns are swapped, then it works:

      select count(*) over(partition by empno order by sal) as count1,
            sum(deptno)  over(partition by empno order by sal) as sum1,
            count(*) over(partition by deptno order by sal) as count2
      from emp
      

      Essentially, the window functions which "share the same window definition" should be placed consecutively in the select-list; Otherwise, the current linking mechanism seems having some difficulty.

      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:

              Slack

                Issue deployment