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

Calcite incorrectly permutes columns of OVER query

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.5.0
    • Component/s: None
    • Labels:
      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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: