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

When Group By clause is present, the argument in window function should not refer to any column outside Group By

    XMLWordPrintableJSON

    Details

      Description

      CTAS

      0: jdbc:drill:schema=dfs.tmp> create table tblForView(col_int, col_bigint, col_char_2, col_vchar_52, col_tmstmp, col_dt, col_booln, col_dbl, col_tm) as select cast(columns[0] as INT), cast(columns[1] as BIGINT),cast(columns[2] as CHAR(2)), cast(columns[3] as VARCHAR(52)), cast(columns[4] as TIMESTAMP), cast(columns[5] as DATE), cast(columns[6] as BOOLEAN),cast(columns[7] as DOUBLE),cast(columns[8] as TIME) from `forPrqView.csv`;
      +-----------+----------------------------+
      | Fragment  | Number of records written  |
      +-----------+----------------------------+
      | 0_0       | 30                         |
      +-----------+----------------------------+
      1 row selected (0.586 seconds)
      

      Failing query

      0: jdbc:drill:schema=dfs.tmp> select max(col_tm) over(), col_char_2 from tblForView group by col_char_2;
      Error: SYSTEM ERROR: java.lang.AssertionError: Internal error: while converting MAX(`tblForView`.`col_tm`)
      
      
      [Error Id: 11afbdc9-d47a-4a52-aa77-40c20ffd2bc6 on centos-03.qa.lab:31010] (state=,code=0)
      

      Stack trace

      [Error Id: 11afbdc9-d47a-4a52-aa77-40c20ffd2bc6 on centos-03.qa.lab:31010]
      org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: java.lang.AssertionError: Internal error: while converting MAX(`tblForView`.`col_tm`)
      
      
      [Error Id: 11afbdc9-d47a-4a52-aa77-40c20ffd2bc6 on centos-03.qa.lab:31010]
              at org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:522) ~[drill-common-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman$ForemanResult.close(Foreman.java:738) [drill-java-exec-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman$StateSwitch.processEvent(Foreman.java:840) [drill-java-exec-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman$StateSwitch.processEvent(Foreman.java:782) [drill-java-exec-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              at org.apache.drill.common.EventProcessor.sendEvent(EventProcessor.java:73) [drill-common-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman$StateSwitch.moveToState(Foreman.java:784) [drill-java-exec-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman.moveToState(Foreman.java:893) [drill-java-exec-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:253) [drill-java-exec-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_45]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_45]
              at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
      Caused by: org.apache.drill.exec.work.foreman.ForemanException: Unexpected exception during fragment initialization: Internal error: while converting MAX(`tblForView`.`col_tm`)
              ... 4 common frames omitted
      Caused by: java.lang.AssertionError: Internal error: while converting MAX(`tblForView`.`col_tm`)
              at org.apache.calcite.util.Util.newInternal(Util.java:790) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.ReflectiveConvertletTable$2.convertCall(ReflectiveConvertletTable.java:152) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlNodeToRexConverterImpl.convertCall(SqlNodeToRexConverterImpl.java:60) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter.convertOver(SqlToRelConverter.java:1762) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter.access$1000(SqlToRelConverter.java:180) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:3938) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter.createAggImpl(SqlToRelConverter.java:2521) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter.convertAgg(SqlToRelConverter.java:2342) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:604) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:564) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:2741) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:522) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.prepare.PlannerImpl.convert(PlannerImpl.java:198) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToRel(DefaultSqlHandler.java:246) ~[drill-java-exec-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.getPlan(DefaultSqlHandler.java:182) ~[drill-java-exec-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              at org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan(DrillSqlWorker.java:178) ~[drill-java-exec-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman.runSQL(Foreman.java:904) [drill-java-exec-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:242) [drill-java-exec-1.1.0-SNAPSHOT-rebuffed.jar:1.1.0-SNAPSHOT]
              ... 3 common frames omitted
      Caused by: java.lang.reflect.InvocationTargetException: null
              at sun.reflect.GeneratedMethodAccessor129.invoke(Unknown Source) ~[na:na]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_45]
              at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_45]
              at org.apache.calcite.sql2rel.ReflectiveConvertletTable$2.convertCall(ReflectiveConvertletTable.java:142) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              ... 19 common frames omitted
      Caused by: java.lang.AssertionError: null
              at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.getRootField(SqlToRelConverter.java:3811) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter.adjustInputRef(SqlToRelConverter.java:3139) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter.convertIdentifier(SqlToRelConverter.java:3114) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter.access$1400(SqlToRelConverter.java:180) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4062) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:3490) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql.SqlIdentifier.accept(SqlIdentifier.java:274) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:3945) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.StandardConvertletTable.convertExpressionList(StandardConvertletTable.java:833) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              at org.apache.calcite.sql2rel.StandardConvertletTable.convertAggregateFunction(StandardConvertletTable.java:706) ~[calcite-core-1.1.0-drill-r8.jar:1.1.0-drill-r8]
              ... 23 common frames omitted
      

        Attachments

        1. forPrqView.csv
          4 kB
          Khurram Faraaz
        2. DRILL-3344.1.patch
          4 kB
          Sean Hsuan-Yi Chu

          Issue Links

            Activity

              People

              • Assignee:
                seanhychu Sean Hsuan-Yi Chu
                Reporter:
                khfaraaz Khurram Faraaz
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: