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

ASF GitHub Bot commented on DRILL-5188:
---------------------------------------

vvysotskyi opened a new pull request #1321:  DRILL-5188: Expand sub-queries 
using rules
URL: https://github.com/apache/drill/pull/1321
 
 
   Before this change, sub-queries were rewritten in `SqlToRelConverter`. 
During such expansion, excessive aggregate calls were created. Due to these 
excessive aggregate calls, some rel nodes weren't able to transpose to 
Aggregate rel node and the resulting plan was inefficient and in the most cases 
with joins with true in condition. As discussed in 
[CALCITE-2158](https://issues.apache.org/jira/browse/CALCITE-2158), a better 
approach to expand sub-queries is to use `SubQueryRemoveRule` rules.
   
   This PR contains two commits:
   - the first one contains changes to use `SubQueryRemoveRule` rules instead 
of expanding in `SqlToRelConverter`.
   - the second commit contains introducing single_value aggregate function 
which is used when filter contains a comparison of value and subquery and in 
some `SubQueryRemoveRule` rules.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> TPC-DS query16 fails - IllegalArgumentException: Target must be less than 
> target count
> --------------------------------------------------------------------------------------
>
>                 Key: DRILL-5188
>                 URL: https://issues.apache.org/jira/browse/DRILL-5188
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Execution - Flow
>    Affects Versions: 1.10.0
>         Environment: 4 node cluster
>            Reporter: Khurram Faraaz
>            Assignee: Volodymyr Vysotskyi
>            Priority: Major
>
> TPC-DS query 16 fails with below Exception. Query 32, Query 92, query 95 also 
> fail due to same Exception, on Drill 1.10.0 (commit ID: bbcf4b76) against SF1 
> data.
> Details from drillbit.log and stack trace.
> {noformat}
> 2017-01-10 11:42:54,769 [278b3740-fa7b-0f27-5c42-92f2f63f7f3d:foreman] INFO  
> o.a.drill.exec.work.foreman.Foreman - Query text for query id 
> 278b3740-fa7b-0f27-5c42-92f2f63f7f3d: SELECT
> Count(DISTINCT cs_order_number) AS `order count` ,
> Sum(cs_ext_ship_cost)           AS `total shipping cost` ,
> Sum(cs_net_profit)              AS `total net profit`
> FROM     catalog_sales cs1 ,
> date_dim ,
> customer_address ,
> call_center
> WHERE    d_date BETWEEN '2002-3-01' AND      (
> Cast('2002-3-01' AS DATE) + INTERVAL '60' day)
> AND      cs1.cs_ship_date_sk = d_date_sk
> AND      cs1.cs_ship_addr_sk = ca_address_sk
> AND      ca_state = 'IA'
> AND      cs1.cs_call_center_sk = cc_call_center_sk
> AND      cc_county IN ('Williamson County',
> 'Williamson County',
> 'Williamson County',
> 'Williamson County',
> 'Williamson County' )
> AND      EXISTS
> (
> SELECT *
> FROM   catalog_sales cs2
> WHERE  cs1.cs_order_number = cs2.cs_order_number
> AND    cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk)
> AND      NOT EXISTS
> (
> SELECT *
> FROM   catalog_returns cr1
> WHERE  cs1.cs_order_number = cr1.cr_order_number)
> ORDER BY count(DISTINCT cs_order_number)
> LIMIT 100
> 2017-01-10 11:42:54,887 [278b3740-fa7b-0f27-5c42-92f2f63f7f3d:foreman] INFO  
> o.a.d.exec.store.dfs.FileSelection - FileSelection.getStatuses() took 0 ms, 
> numFiles: 1
> 2017-01-10 11:42:54,888 [278b3740-fa7b-0f27-5c42-92f2f63f7f3d:foreman] INFO  
> o.a.d.exec.store.dfs.FileSelection - FileSelection.getStatuses() took 0 ms, 
> numFiles: 1
> 2017-01-10 11:42:54,895 [278b3740-fa7b-0f27-5c42-92f2f63f7f3d:foreman] INFO  
> o.a.d.exec.store.dfs.FileSelection - FileSelection.getStatuses() took 0 ms, 
> numFiles: 1
> 2017-01-10 11:42:54,895 [278b3740-fa7b-0f27-5c42-92f2f63f7f3d:foreman] INFO  
> o.a.d.exec.store.dfs.FileSelection - FileSelection.getStatuses() took 0 ms, 
> numFiles: 1
> 2017-01-10 11:42:54,902 [278b3740-fa7b-0f27-5c42-92f2f63f7f3d:foreman] INFO  
> o.a.d.exec.store.dfs.FileSelection - FileSelection.getStatuses() took 0 ms, 
> numFiles: 1
> 2017-01-10 11:42:54,903 [278b3740-fa7b-0f27-5c42-92f2f63f7f3d:foreman] INFO  
> o.a.d.exec.store.dfs.FileSelection - FileSelection.getStatuses() took 0 ms, 
> numFiles: 1
> 2017-01-10 11:42:54,908 [278b3740-fa7b-0f27-5c42-92f2f63f7f3d:foreman] INFO  
> o.a.d.exec.store.dfs.FileSelection - FileSelection.getStatuses() took 0 ms, 
> numFiles: 1
> 2017-01-10 11:42:54,909 [278b3740-fa7b-0f27-5c42-92f2f63f7f3d:foreman] INFO  
> o.a.d.exec.store.dfs.FileSelection - FileSelection.getStatuses() took 0 ms, 
> numFiles: 1
> 2017-01-10 11:42:54,919 [278b3740-fa7b-0f27-5c42-92f2f63f7f3d:foreman] INFO  
> o.a.d.exec.store.dfs.FileSelection - FileSelection.getStatuses() took 0 ms, 
> numFiles: 1
> 2017-01-10 11:42:54,920 [278b3740-fa7b-0f27-5c42-92f2f63f7f3d:foreman] INFO  
> o.a.d.exec.store.dfs.FileSelection - FileSelection.getStatuses() took 0 ms, 
> numFiles: 1
> 2017-01-10 11:42:54,946 [278b3740-fa7b-0f27-5c42-92f2f63f7f3d:foreman] ERROR 
> o.a.drill.exec.work.foreman.Foreman - SYSTEM ERROR: IllegalArgumentException: 
> Target must be less than target count, 3
> [Error Id: 61befda9-3479-48a4-a6ff-181703aea1b7 on centos-01.qa.lab:31010]
> org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: 
> IllegalArgumentException: Target must be less than target count, 3
> [Error Id: 61befda9-3479-48a4-a6ff-181703aea1b7 on centos-01.qa.lab:31010]
>         at 
> org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:544)
>  ~[drill-common-1.10.0-SNAPSHOT.jar:1.10.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.work.foreman.Foreman$ForemanResult.close(Foreman.java:824)
>  [drill-java-exec-1.10.0-SNAPSHOT.jar:1.10.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.work.foreman.Foreman.moveToState(Foreman.java:944) 
> [drill-java-exec-1.10.0-SNAPSHOT.jar:1.10.0-SNAPSHOT]
>         at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:281) 
> [drill-java-exec-1.10.0-SNAPSHOT.jar:1.10.0-SNAPSHOT]
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>  [na:1.8.0_91]
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>  [na:1.8.0_91]
>         at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91]
> Caused by: org.apache.drill.exec.work.foreman.ForemanException: Unexpected 
> exception during fragment initialization: Target must be less than target 
> count, 3
>         ... 4 common frames omitted
> Caused by: java.lang.IllegalArgumentException: Target must be less than 
> target count, 3
>         at 
> org.apache.calcite.util.mapping.Mappings$PartialFunctionImpl.set(Mappings.java:1642)
>  ~[calcite-core-1.4.0-drill-r19.jar:1.4.0-drill-r19]
>         at org.apache.calcite.util.mapping.Mappings.target(Mappings.java:343) 
> ~[calcite-core-1.4.0-drill-r19.jar:1.4.0-drill-r19]
>         at 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelateRel(RelDecorrelator.java:411)
>  ~[calcite-core-1.4.0-drill-r19.jar:1.4.0-drill-r19]
>         at sun.reflect.GeneratedMethodAccessor237.invoke(Unknown Source) 
> ~[na:na]
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  ~[na:1.8.0_91]
>         at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_91]
>         at 
> org.apache.calcite.util.ReflectUtil.invokeVisitorInternal(ReflectUtil.java:257)
>  ~[calcite-core-1.4.0-drill-r19.jar:1.4.0-drill-r19]
>         at 
> org.apache.calcite.util.ReflectUtil.invokeVisitor(ReflectUtil.java:214) 
> ~[calcite-core-1.4.0-drill-r19.jar:1.4.0-drill-r19]
>         at 
> org.apache.calcite.util.ReflectUtil$1.invokeVisitor(ReflectUtil.java:471) 
> ~[calcite-core-1.4.0-drill-r19.jar:1.4.0-drill-r19]
>         at 
> org.apache.calcite.sql2rel.RelDecorrelator$DecorrelateRelVisitor.visit(RelDecorrelator.java:1433)
>  ~[calcite-core-1.4.0-drill-r19.jar:1.4.0-drill-r19]
>         at 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelate(RelDecorrelator.java:238)
>  ~[calcite-core-1.4.0-drill-r19.jar:1.4.0-drill-r19]
>         at 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelateQuery(RelDecorrelator.java:205)
>  ~[calcite-core-1.4.0-drill-r19.jar:1.4.0-drill-r19]
>         at 
> org.apache.drill.exec.planner.sql.SqlConverter.toRel(SqlConverter.java:265) 
> ~[drill-java-exec-1.10.0-SNAPSHOT.jar:1.10.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToRel(DefaultSqlHandler.java:626)
>  ~[drill-java-exec-1.10.0-SNAPSHOT.jar:1.10.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.validateAndConvert(DefaultSqlHandler.java:195)
>  ~[drill-java-exec-1.10.0-SNAPSHOT.jar:1.10.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.getPlan(DefaultSqlHandler.java:164)
>  ~[drill-java-exec-1.10.0-SNAPSHOT.jar:1.10.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.planner.sql.DrillSqlWorker.getPhysicalPlan(DrillSqlWorker.java:122)
>  ~[drill-java-exec-1.10.0-SNAPSHOT.jar:1.10.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan(DrillSqlWorker.java:96)
>  ~[drill-java-exec-1.10.0-SNAPSHOT.jar:1.10.0-SNAPSHOT]
>         at 
> org.apache.drill.exec.work.foreman.Foreman.runSQL(Foreman.java:1017) 
> [drill-java-exec-1.10.0-SNAPSHOT.jar:1.10.0-SNAPSHOT]
>         at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:264) 
> [drill-java-exec-1.10.0-SNAPSHOT.jar:1.10.0-SNAPSHOT]
>         ... 3 common frames omitted
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to