Khurram Faraaz created DRILL-2694: ------------------------------------- Summary: Correlated subquery can not be planned Key: DRILL-2694 URL: https://issues.apache.org/jira/browse/DRILL-2694 Project: Apache Drill Issue Type: Bug Components: Query Planning & Optimization Affects Versions: 0.9.0 Environment: 9d92b8e319f2d46e8659d903d355450e15946533 | DRILL-2580: Exit early from HashJoinBatch if build side is empty | 26.03.2015 @ 16:13:53 EDT Reporter: Khurram Faraaz Assignee: Jinfeng Ni
Correlated subquery can not be planned. Test was run on 4 node cluster on CentOS. Please note that Physical plan tab and Visualized plan tabs were empty for the below query. {code} 0: jdbc:drill:> select * from `allTypData.csv` t1 where t1.columns[0] > (select min(columns[0]) from `allTypData2.csv` t2); Query failed: UnsupportedRelOperatorException: This query cannot be planned possibly due to either a cartesian join or an inequality join Error: exception while executing query: Failure while executing query. (state=,code=0) Table in outer query has 295 rows. 0: jdbc:drill:> select count(*) from `allTypData.csv`; +------------+ | EXPR$0 | +------------+ | 295 | +------------+ 1 row selected (0.082 seconds) Table in inner query has 999 rows. 0: jdbc:drill:> select count(*) from `allTypData2.csv`; +------------+ | EXPR$0 | +------------+ | 999 | +------------+ 1 row selected (0.083 seconds) sub query is, 0: jdbc:drill:> select min(columns[0]) from `allTypData2.csv`; +------------+ | EXPR$0 | +------------+ | -1000041497 | +------------+ 1 row selected (0.097 seconds) Note that when we replace the sub-query with the value that the sub-query returns, the original query returns results. It fails only when there is correlated subquery. select * from `allTypData.csv` t1 where t1.columns[0] > -1000041497; +------------+ | columns | +------------+ ... +------------+ 214 rows selected (0.162 seconds) 0: jdbc:drill:> explain plan for select * from `allTypData.csv` t1 where t1.columns[0] > (select min(columns[0]) from `allTypData2.csv` t2); Query failed: UnsupportedRelOperatorException: This query cannot be planned possibly due to either a cartesian join or an inequality join Error: exception while executing query: Failure while executing query. (state=,code=0) {code} Stack trace from drillbit.log {code} 2015-04-04 21:12:40,687 [2adfac37-037b-c692-31b1-41d8004d9b13:foreman] INFO o.a.drill.exec.work.foreman.Foreman - State change requested. PENDING --> FAILED org.apache.drill.exec.work.foreman.UnsupportedRelOperatorException: This query cannot be planned possibly due to either a cartesian join or an inequality join at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToDrel(DefaultSqlHandler.java:217) ~[drill-java-exec-0.9.0-SNAPSHOT-rebuffed.jar:0.9.0-SNAPSHOT] at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.getPlan(DefaultSqlHandler.java:138) ~[drill-java-exec-0.9.0-SNAPSHOT-rebuffed.jar:0.9.0-SNAPSHOT] at org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan(DrillSqlWorker.java:145) ~[drill-java-exec-0.9.0-SNAPSHOT-rebuffed.jar:0.9.0-SNAPSHOT] at org.apache.drill.exec.work.foreman.Foreman.runSQL(Foreman.java:773) ~[drill-java-exec-0.9.0-SNAPSHOT-rebuffed.jar:0.9.0-SNAPSHOT] at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:204) ~[drill-java-exec-0.9.0-SNAPSHOT-rebuffed.jar:0.9.0-SNAPSHOT] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_75] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_75] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_75] 2015-04-04 21:12:40,695 [2adfac37-037b-c692-31b1-41d8004d9b13:foreman] INFO o.a.drill.exec.work.foreman.Foreman - foreman cleaning up - status: [] 2015-04-04 21:12:40,696 [2adfac37-037b-c692-31b1-41d8004d9b13:foreman] ERROR o.a.drill.exec.work.foreman.Foreman - Error 59dcbb50-d418-400a-9c0c-7331fcb6b344: UnsupportedRelOperatorException: This query cannot be planned possibly due to either a cartesian join or an inequality join org.apache.drill.exec.work.foreman.UnsupportedRelOperatorException: This query cannot be planned possibly due to either a cartesian join or an inequality join at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToDrel(DefaultSqlHandler.java:217) ~[drill-java-exec-0.9.0-SNAPSHOT-rebuffed.jar:0.9.0-SNAPSHOT] at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.getPlan(DefaultSqlHandler.java:138) ~[drill-java-exec-0.9.0-SNAPSHOT-rebuffed.jar:0.9.0-SNAPSHOT] at org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan(DrillSqlWorker.java:145) ~[drill-java-exec-0.9.0-SNAPSHOT-rebuffed.jar:0.9.0-SNAPSHOT] at org.apache.drill.exec.work.foreman.Foreman.runSQL(Foreman.java:773) ~[drill-java-exec-0.9.0-SNAPSHOT-rebuffed.jar:0.9.0-SNAPSHOT] at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:204) ~[drill-java-exec-0.9.0-SNAPSHOT-rebuffed.jar:0.9.0-SNAPSHOT] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_75] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_75] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_75] {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)