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

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

rymarm opened a new pull request, #2944:
URL: https://github.com/apache/drill/pull/2944

   # [DRILL-8512](https://issues.apache.org/jira/browse/DRILL-XXXX): 
ReduceAndSimplifyFilterRule fails with NullPointerException
   
   ## Description
   I'm not sure why the following issue wasn't before, but it's clear, why the 
issue appears at all - because we provide neither inputs `RelNode`s(we calling 
`DrillOptiq.toDrill` with `null` for the input, see code change) or 
`RexBuilder` along with `RelDataType`.
   
   ## Documentation
   -
   
   ## Testing
   Tested with the query the issue was reproduced:
   ```sql
   SELECT *
   FROM
   (
   SELECT
   (CASE WHEN (true) THEN 'qwe' ELSE null END) res1
   FROM (VALUES(1)) test_tbl
   ) test
   where res1 IN ('ab','dab','qw','qwe') 
   ```
   




> ReduceAndSimplifyFilterRule fails with NullPointerException
> -----------------------------------------------------------
>
>                 Key: DRILL-8512
>                 URL: https://issues.apache.org/jira/browse/DRILL-8512
>             Project: Apache Drill
>          Issue Type: Bug
>            Reporter: Maksym Rymar
>            Assignee: Maksym Rymar
>            Priority: Minor
>
> Drill fails to execute the following query:
> {code:java}
> SELECT *
> FROM
> (
> SELECT
> (CASE WHEN (true) THEN 'qwe' ELSE null END) res1
> FROM (VALUES(1)) test_tbl
> ) test
> where res1 IN ('ab','dab','qw','qwe') {code}
> The exception:
> {code:java}
> Unexpected exception during fragment initialization: Error while applying 
> rule ReduceAndSimplifyFilterRule, args 
> [rel#760:LogicalFilter.NONE.ANY([]).[0](input=RelSubset#744,condition=SEARCH(CAST('qwe'):CHAR(3),
>  Sarg['ab':CHAR(3), 'dab', 'qw':CHAR(3), 'qwe']:CHAR(3)))]
>     org.apache.drill.exec.work.foreman.Foreman.run():303
>     java.util.concurrent.ThreadPoolExecutor.runWorker():1128
>     java.util.concurrent.ThreadPoolExecutor$Worker.run():628
>     java.lang.Thread.run():829
>   Caused By (java.lang.RuntimeException) Error while applying rule 
> ReduceAndSimplifyFilterRule, args 
> [rel#760:LogicalFilter.NONE.ANY([]).[0](input=RelSubset#744,condition=SEARCH(CAST('qwe'):CHAR(3),
>  Sarg['ab':CHAR(3), 'dab', 'qw':CHAR(3), 'qwe']:CHAR(3)))]
>     org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch():250
>     org.apache.calcite.plan.volcano.IterativeRuleDriver.drive():59
>     org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp():523
>     org.apache.calcite.tools.Programs$RuleSetProgram.run():317
>     
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.transform():405
>     
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.transform():351
>     
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToRawDrel():245
>     
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToDrel():308
>     org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.getPlan():176
>     org.apache.drill.exec.planner.sql.DrillSqlWorker.getQueryPlan():298
>     org.apache.drill.exec.planner.sql.DrillSqlWorker.getPhysicalPlan():179
>     org.apache.drill.exec.planner.sql.DrillSqlWorker.convertPlan():129
>     org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan():94
>     org.apache.drill.exec.work.foreman.Foreman.runSQL():597
>     org.apache.drill.exec.work.foreman.Foreman.run():276
>     java.util.concurrent.ThreadPoolExecutor.runWorker():1128
>     java.util.concurrent.ThreadPoolExecutor$Worker.run():628
>     java.lang.Thread.run():829
>   Caused By (java.lang.NullPointerException) null
>     org.apache.calcite.rex.RexUtil.lambda$sargRef$1():633
>     com.google.common.collect.ImmutableList.forEach():422
>     com.google.common.collect.RegularImmutableSortedSet.forEach():89
>     org.apache.calcite.rex.RexUtil.sargRef():630
>     org.apache.calcite.rex.RexUtil$SearchExpandingShuttle.visitCall():3143
>     org.apache.calcite.rex.RexUtil$SearchExpandingShuttle.visitCall():3106
>     org.apache.calcite.rex.RexCall.accept():189
>     org.apache.calcite.rex.RexUtil.expandSearch():601
>     org.apache.calcite.rex.RexUtil.expandSearch():594
>     
> org.apache.drill.exec.planner.logical.DrillOptiq$RexToDrill.visitCall():277
>     
> org.apache.drill.exec.planner.logical.DrillOptiq$RexToDrill.visitCall():120
>     org.apache.calcite.rex.RexCall.accept():189
>     org.apache.drill.exec.planner.logical.DrillOptiq.toDrill():112
>     org.apache.drill.exec.planner.logical.DrillOptiq.toDrill():99
>     org.apache.drill.exec.planner.logical.DrillConstExecutor.reduce():138
>     
> org.apache.calcite.rel.rules.ReduceExpressionsRule.reduceExpressionsInternal():771
>     org.apache.calcite.rel.rules.ReduceExpressionsRule.reduceExpressions():711
>     
> org.apache.calcite.rel.rules.ReduceExpressionsRule$FilterReduceExpressionsRule.onMatch():154
>     
> org.apache.drill.exec.planner.logical.ReduceAndSimplifyExpressionsRules$ReduceAndSimplifyFilterRule.onMatch():68
>     org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch():223
>     org.apache.calcite.plan.volcano.IterativeRuleDriver.drive():59
>     org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp():523
>     org.apache.calcite.tools.Programs$RuleSetProgram.run():317
>     
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.transform():405
>     
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.transform():351
>     
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToRawDrel():245
>     
> org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToDrel():308
>     org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.getPlan():176
>     org.apache.drill.exec.planner.sql.DrillSqlWorker.getQueryPlan():298
>     org.apache.drill.exec.planner.sql.DrillSqlWorker.getPhysicalPlan():179
>     org.apache.drill.exec.planner.sql.DrillSqlWorker.convertPlan():129
>     org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan():94
>     org.apache.drill.exec.work.foreman.Foreman.runSQL():597
>     org.apache.drill.exec.work.foreman.Foreman.run():276
>     java.util.concurrent.ThreadPoolExecutor.runWorker():1128
>     java.util.concurrent.ThreadPoolExecutor$Worker.run():628
>     java.lang.Thread.run():829 {code}
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to