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

Invalid nested window aggregate query with alias

    Details

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

      Description

      The following query should fail but does not!

      SELECT max(sum(sal)) OVER (partition by deptno) AS maxSal
      FROM emp
      WHERE deptno > 10;
      

        Activity

        Hide
        gparai Gautam Kumar Parai added a comment -

        This case was missed in CALCITE-1327, CALCITE-1340. The scope is not considered AggregatingScope because we do not find nested window aggregates. Only the top-level select list items are considered for the OVER clause. Instead, we should use the overFinder since the OVER clause will not occur in the top level as in the example above.

        Show
        gparai Gautam Kumar Parai added a comment - This case was missed in CALCITE-1327 , CALCITE-1340 . The scope is not considered AggregatingScope because we do not find nested window aggregates. Only the top-level select list items are considered for the OVER clause. Instead, we should use the overFinder since the OVER clause will not occur in the top level as in the example above.
        Hide
        gparai Gautam Kumar Parai added a comment - - edited

        Julian Hyde I missed this case in the earlier fixes. I have created a pull request (https://github.com/apache/calcite/pull/267) to address it. Could you please review it? Thanks!!

        Show
        gparai Gautam Kumar Parai added a comment - - edited Julian Hyde I missed this case in the earlier fixes. I have created a pull request ( https://github.com/apache/calcite/pull/267 ) to address it. Could you please review it? Thanks!!
        Hide
        gparai Gautam Kumar Parai added a comment - - edited

        Aman SinhaJinfeng Ni Can you please review the PR since Julian is on vacation? I have created a pull request (https://github.com/apache/calcite/pull/267) t

        Show
        gparai Gautam Kumar Parai added a comment - - edited Aman Sinha Jinfeng Ni Can you please review the PR since Julian is on vacation? I have created a pull request ( https://github.com/apache/calcite/pull/267 ) t
        Hide
        amansinha100 Aman Sinha added a comment -

        LGTM. +1

        Show
        amansinha100 Aman Sinha added a comment - LGTM. +1
        Show
        gparai Gautam Kumar Parai added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/fd4f85e
        Hide
        jcamachorodriguez Jesus Camacho Rodriguez added a comment -

        Resolved in release 1.9.0 (2016-09-22)

        Show
        jcamachorodriguez Jesus Camacho Rodriguez added a comment - Resolved in release 1.9.0 (2016-09-22)

          People

          • Assignee:
            gparai Gautam Kumar Parai
            Reporter:
            gparai Gautam Kumar Parai
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development