[ 
https://issues.apache.org/jira/browse/DRILL-4807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15394791#comment-15394791
 ] 

Zelaine Fong commented on DRILL-4807:
-------------------------------------

[~khfaraaz] - Just to confirm – this issue is not a result of the changes made 
for DRILL-2330.

> ORDER BY aggregate function in window definition results in AssertionError: 
> Internal error: invariant violated: conversion result not null
> ------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DRILL-4807
>                 URL: https://issues.apache.org/jira/browse/DRILL-4807
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Execution - Flow
>    Affects Versions: 1.8.0
>            Reporter: Khurram Faraaz
>              Labels: window_function
>
> This seems to be a problem when regular window function queries, when 
> aggregate function is used in ORDER BY clause inside the window definition.
> MapR Drill 1.8.0 commit ID : 34ca63ba
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> SELECT col0, SUM(col0) OVER ( PARTITION BY col7 
> ORDER BY MIN(col8)) avg_col0, col7 FROM `allTypsUniq.parquet` GROUP BY 
> col0,col8,col7;
> Error: SYSTEM ERROR: AssertionError: Internal error: invariant violated: 
> conversion result not null
> [Error Id: 19a3eced-aaaa-4e83-ae0f-6b8ea21b2afd on centos-01.qa.lab:31010] 
> (state=,code=0)
> {noformat}
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> SELECT col0, AVG(col0) OVER ( PARTITION BY col7 
> ORDER BY MIN(col8)) avg_col0, col7 FROM `allTypsUniq.parquet` GROUP BY 
> col0,col8,col7;
> Error: SYSTEM ERROR: AssertionError: Internal error: invariant violated: 
> conversion result not null
> [Error Id: c9b7ebf2-6097-41d8-bb73-d57da4ace8ad on centos-01.qa.lab:31010] 
> (state=,code=0)
> {noformat}
> Stack trace from drillbit.log
> {noformat}
> 2016-07-26 09:26:16,717 [2868d347-3124-0c58-89ff-19e4ee891031:foreman] INFO  
> o.a.drill.exec.work.foreman.Foreman - Query text for query id 
> 2868d347-3124-0c58-89ff-19e4ee891031: SELECT col0, AVG(col0) OVER ( PARTITION 
> BY col7 ORDER BY MIN(col8)) avg_col0, col7 FROM `allTypsUniq.parquet` GROUP 
> BY col0,col8,col7
> 2016-07-26 09:26:16,751 [2868d347-3124-0c58-89ff-19e4ee891031:foreman] ERROR 
> o.a.drill.exec.work.foreman.Foreman - SYSTEM ERROR: AssertionError: Internal 
> error: invariant violated: conversion result not null
> [Error Id: c9b7ebf2-6097-41d8-bb73-d57da4ace8ad on centos-01.qa.lab:31010]
> org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: 
> AssertionError: Internal error: invariant violated: conversion result not null
> [Error Id: c9b7ebf2-6097-41d8-bb73-d57da4ace8ad on centos-01.qa.lab:31010]
>         at 
> org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543)
>  ~[drill-common-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.work.foreman.Foreman$ForemanResult.close(Foreman.java:791)
>  [drill-java-exec-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.work.foreman.Foreman.moveToState(Foreman.java:901) 
> [drill-java-exec-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
>         at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:271) 
> [drill-java-exec-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>  [na:1.7.0_101]
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>  [na:1.7.0_101]
>         at java.lang.Thread.run(Thread.java:745) [na:1.7.0_101]
> Caused by: org.apache.drill.exec.work.foreman.ForemanException: Unexpected 
> exception during fragment initialization: Internal error: invariant violated: 
> conversion result not null
>         ... 4 common frames omitted
> Caused by: java.lang.AssertionError: Internal error: invariant violated: 
> conversion result not null
>         at org.apache.calcite.util.Util.newInternal(Util.java:777) 
> ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at org.apache.calcite.util.Util.permAssert(Util.java:885) 
> ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4063)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertSortExpression(SqlToRelConverter.java:4080)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertOver(SqlToRelConverter.java:1783)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter.access$1100(SqlToRelConverter.java:185)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4055)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.StandardConvertletTable$8.convertCall(StandardConvertletTable.java:185)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlNodeToRexConverterImpl.convertCall(SqlNodeToRexConverterImpl.java:59)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4170)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:3603)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:130) 
> ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4062)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter.createAggImpl(SqlToRelConverter.java:2575)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertAgg(SqlToRelConverter.java:2392)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:622)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:583)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:2795)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:537)
>  ~[calcite-core-1.4.0-drill-r14.jar:1.4.0-drill-r14]
>         at 
> org.apache.drill.exec.planner.sql.SqlConverter.toRel(SqlConverter.java:251) 
> ~[drill-java-exec-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToRel(DefaultSqlHandler.java:620)
>  ~[drill-java-exec-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.validateAndConvert(DefaultSqlHandler.java:195)
>  ~[drill-java-exec-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.getPlan(DefaultSqlHandler.java:164)
>  ~[drill-java-exec-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan(DrillSqlWorker.java:94)
>  ~[drill-java-exec-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.work.foreman.Foreman.runSQL(Foreman.java:978) 
> [drill-java-exec-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
>         at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:257) 
> [drill-java-exec-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
> {noformat}
> Postgres returns results for the same data.
> {noformat}
> postgres=# SELECT col0, AVG(col0) OVER ( PARTITION BY col7 ORDER BY 
> MIN(col8)) avg_col0, col7 FROM fewrwspqq_101 GROUP BY col0,col8,col7;
>     col0    |        avg_col0        | col7 
> ------------+------------------------+------
>           1 | 1.00000000000000000000 | f
>          13 |     7.0000000000000000 | f
>           7 |     7.0000000000000000 | f
>  2147483647 |     536870917.00000000 | f
>           0 |     429496733.60000000 | f
>  1073741823 |     536870915.16666667 | f
>          29 |     460175074.28571429 | f
>      -65535 |     402644998.12500000 | f
>           3 |     357906665.33333333 | f
>           9 |     322115999.70000000 | f
>           5 |     292832727.45454545 | f
>           4 |     4.0000000000000000 | t
>           6 |     5.0000000000000000 | t
>          10 |     6.6666666666666667 | t
>       65535 |     16388.750000000000 | t
>         109 |     13132.800000000000 | t
>    10000000 |   1677610.666666666667 | t
>          23 |   1437955.285714285714 | t
>           8 |   1258211.875000000000 | t
>          -1 |   1118410.444444444444 | t
>           2 |   1006569.600000000000 | t
>          19 |    915065.000000000000 | t
> (22 rows)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to