Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-4902

nested aggregate query does not complain about missing GROUP BY clause

    XMLWordPrintableJSON

Details

    Description

      A nested aggregate windowed query does not report an error when the partitioning column is not used in the GROUP BY clause.
      Drill 1.9.0

      This is the correct expected behavior.

      0: jdbc:drill:schema=dfs.tmp> select count(max(c7)) over (partition by c8) from `DRILL_4589`;
      Error: VALIDATION ERROR: From line 1, column 42 to line 1, column 43: Expression 'c8' is not being grouped
      
      SQL Query null
      
      [Error Id: 09c837b9-7a66-4a1f-9fbc-522160947274 on centos-01.qa.lab:31010] (state=,code=0)
      

      The below query too should report above error, as the GROUP BY on partitioning column is missing.

      0: jdbc:drill:schema=dfs.tmp> select count(max(c7)) over (partition by c8) from (select * from `DRILL_4589`);
      +---------+
      | EXPR$0  |
      +---------+
      | 1       |
      +---------+
      1 row selected (193.71 seconds)
      

      Postgres 9.3 also reports an error for a similar query

      postgres=# select count(max(c1)) over (partition by c2) from (select * from t222) sub_query;
      ERROR:  column "sub_query.c2" must appear in the GROUP BY clause or be used in an aggregate function
      LINE 1: select count(max(c1)) over (partition by c2) from (select * ...
      

      Attachments

        Activity

          People

            gparai Gautam Parai
            khfaraaz Khurram Faraaz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: