You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by "Jinfeng Ni (JIRA)" <ji...@apache.org> on 2015/06/26 20:48:04 UTC

[jira] [Resolved] (DRILL-3183) When Group By clause is present, the argument in window function should not refer to any column outside Group By

     [ https://issues.apache.org/jira/browse/DRILL-3183?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jinfeng Ni resolved DRILL-3183.
-------------------------------
    Resolution: Fixed

fixed in commit:  da17f28678f1dee5c43bdb69582586a79f8b667c

> When Group By clause is present, the argument in window function should not refer to any column outside Group By
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: DRILL-3183
>                 URL: https://issues.apache.org/jira/browse/DRILL-3183
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Query Planning & Optimization
>    Affects Versions: 1.0.0
>         Environment: faec150598840c40827e6493992d81209aa936da
>            Reporter: Khurram Faraaz
>            Assignee: Sean Hsuan-Yi Chu
>              Labels: window_function
>             Fix For: 1.1.0
>
>
> Test was run on 4 node cluster on CentOS. We see NPE for a query that uses window functions. Data was from CSV file (headers were ignored).
> To enable window functions, 
> alter session set `window.enable`=true;
> These two queries work 
> {code}
> SELECT count(salary) OVER w, count(salary) OVER w FROM cp.`employee.json` t WINDOW w AS (PARTITION BY store_id ORDER BY position_id DESC);
> SELECT count(columns[0]) OVER(PARTITION BY columns[1] ORDER BY columns[0] DESC), count(columns[0]) OVER(PARTITION BY columns[1] ORDER BY columns[0] DESC) FROM `airports.csv`;
> {code}
> These two queries do not work and in the second query we see a NPE
> {code}
> 0: jdbc:drill:schema=dfs.tmp> SELECT count(*) OVER w, count(*) OVER w FROM `airports.csv` WINDOW w AS (PARTITION BY columns[1] ORDER BY columns[0] DESC);
> Error: PARSE ERROR: From line 1, column 87 to line 1, column 93: Table 'columns' not found
> [Error Id: 51d080bc-580f-44cc-a9be-d29ae60900c3 on centos-03.qa.lab:31010] (state=,code=0)
> {code}
> Query that returns NPE.
> {code}
> 0: jdbc:drill:schema=dfs.tmp> SELECT count(*) OVER w, count(*) OVER w FROM `airports.csv` t WINDOW w AS (PARTITION BY t.columns[1] ORDER BY t.columns[0] DESC);
> Error: PARSE ERROR: java.lang.NullPointerException
> [Error Id: 27e933bf-1382-4aae-bfef-36444a69acc9 on centos-03.qa.lab:31010] (state=,code=0)
> {code}
> Stack trace from drillbit.log
> {code}
> 2015-05-26 19:07:33,104 [2a9b3b8a-4d0b-ba7b-f0ff-f8038f9f9dbd:foreman] INFO  o.a.drill.exec.work.foreman.Foreman - State change requested.  PENDING --> FAILED
> org.apache.drill.exec.work.foreman.ForemanException: Unexpected exception during fragment initialization: PARSE ERROR: java.lang.NullPointerException
> [Error Id: 16e17855-32f7-4687-9502-5b4880bb11a4 ]
>         at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:251) [drill-java-exec-1.0.0-mapr-r1-rebuffed.jar:1.0.0-mapr-r1]
>         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.common.exceptions.UserException: PARSE ERROR: java.lang.NullPointerException
> [Error Id: 16e17855-32f7-4687-9502-5b4880bb11a4 ]
>         at org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:522) ~[drill-common-1.0.0-mapr-r1-rebuffed.jar:1.0.0-mapr-r1]
>         at org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan(DrillSqlWorker.java:180) ~[drill-java-exec-1.0.0-mapr-r1-rebuffed.jar:1.0.0-mapr-r1]
>         at org.apache.drill.exec.work.foreman.Foreman.runSQL(Foreman.java:902) [drill-java-exec-1.0.0-mapr-r1-rebuffed.jar:1.0.0-mapr-r1]
>         at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:240) [drill-java-exec-1.0.0-mapr-r1-rebuffed.jar:1.0.0-mapr-r1]
>         ... 3 common frames omitted
> Caused by: org.apache.calcite.tools.ValidationException: java.lang.NullPointerException
>         at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:176) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.prepare.PlannerImpl.validateAndGetType(PlannerImpl.java:185) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.validateNode(DefaultSqlHandler.java:226) ~[drill-java-exec-1.0.0-mapr-r1-rebuffed.jar:1.0.0-mapr-r1]
>         at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.getPlan(DefaultSqlHandler.java:178) ~[drill-java-exec-1.0.0-mapr-r1-rebuffed.jar:1.0.0-mapr-r1]
>         at org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan(DrillSqlWorker.java:177) ~[drill-java-exec-1.0.0-mapr-r1-rebuffed.jar:1.0.0-mapr-r1]
>         ... 5 common frames omitted
> Caused by: java.lang.NullPointerException: null
>         at org.apache.calcite.rel.type.RelDataTypeImpl.getField(RelDataTypeImpl.java:82) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.validate.SqlValidatorUtil.lookupField(SqlValidatorUtil.java:116) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.prepare.CalciteCatalogReader.field(CalciteCatalogReader.java:205) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.validate.DelegatingScope.fullyQualify(DelegatingScope.java:205) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.validate.SqlValidatorImpl.validateIdentifier(SqlValidatorImpl.java:2580) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.SqlIdentifier.validateExpr(SqlIdentifier.java:251) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.SqlWindow.validate(SqlWindow.java:550) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.SqlNodeList.validate(SqlNodeList.java:147) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.validate.SqlValidatorImpl.validateWindowClause(SqlValidatorImpl.java:3010) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:2957) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:86) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:874) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:863) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:210) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:837) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:552) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:174) ~[calcite-core-1.1.0-drill-r7.jar:1.1.0-drill-r7]
>         ... 9 common frames omitted
> {code}



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