Victoria Markman created DRILL-3862:
---------------------------------------

             Summary: Assert in a query during partition pruning with the dir0 
and coalesce function 
                 Key: DRILL-3862
                 URL: https://issues.apache.org/jira/browse/DRILL-3862
             Project: Apache Drill
          Issue Type: Bug
          Components: Query Planning & Optimization
    Affects Versions: 1.2.0
            Reporter: Victoria Markman
         Attachments: orders.tar

Enable asserts, run query below. Table is attached.
Somewhat similar to DRILL-3667, reproduces consistently.

{code}
select
        count(*)
from
        `/drill/testdata/partition_pruning/dfs/orders`
where
        dir0 = coalesce(o_orderdate, '1993') and o_custkey >= 100;
{code}


-- Assert
{code}
0: jdbc:drill:schema=dfs> select
. . . . . . . . . . . . >         count(*)
. . . . . . . . . . . . > from
. . . . . . . . . . . . >         `/drill/testdata/partition_pruning/dfs/orders`
. . . . . . . . . . . . > where
. . . . . . . . . . . . >         dir0 = coalesce(o_orderdate, '1993') and 
o_custkey >= 100;
Error: SYSTEM ERROR: AssertionError
[Error Id: 8533447a-1d36-4d25-9a5f-1cb22770de9b on atsqa4-133.qa.lab:31010] 
(state=,code=0)
{code}


-- works: just coalesce
{code}
0: jdbc:drill:schema=dfs> select
. . . . . . . . . . . . >         count(*)
. . . . . . . . . . . . > from
. . . . . . . . . . . . >         `/drill/testdata/partition_pruning/dfs/orders`
. . . . . . . . . . . . > where
. . . . . . . . . . . . >         dir0 = coalesce(o_orderdate, '1993');
+---------+
| EXPR$0  |
+---------+
| 0       |
+---------+
1 row selected (0.351 seconds)
{code}

-- works: date_part function
{code}
0: jdbc:drill:schema=dfs> select
. . . . . . . . . . . . >         count(*)
. . . . . . . . . . . . > from
. . . . . . . . . . . . >         
`/drill/testdata/partition_pruning/dfs/orders`. . . . . . . . . . . . > where. 
. . . . . . . . . . . >         date_part('year', o_orderdate) = 
dir0;+---------+
| EXPR$0  |
+---------+| 2281    |+---------+
1 row selected (0.43 seconds)
{code}

drillbit.log
{code}
015-09-29 23:04:10,664 [29f4e714-fc3e-f2c0-6ad2-0f024c1df78f:foreman] ERROR 
o.a.drill.exec.work.foreman.Foreman - SYSTEM ERROR: AssertionError
[Error Id: 8533447a-1d36-4d25-9a5f-1cb22770de9b on atsqa4-133.qa.lab:31010]
org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: AssertionError
[Error Id: 8533447a-1d36-4d25-9a5f-1cb22770de9b on atsqa4-133.qa.lab:31010]
        at 
org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:534)
 ~[drill-common-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.work.foreman.Foreman$ForemanResult.close(Foreman.java:742)
 [drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.work.foreman.Foreman$StateSwitch.processEvent(Foreman.java:841)
 [drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.work.foreman.Foreman$StateSwitch.processEvent(Foreman.java:786)
 [drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.common.EventProcessor.sendEvent(EventProcessor.java:73) 
[drill-common-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.work.foreman.Foreman$StateSwitch.moveToState(Foreman.java:788)
 [drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.work.foreman.Foreman.moveToState(Foreman.java:894) 
[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:255) 
[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
[na:1.7.0_71]
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
[na:1.7.0_71]
        at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71]
Caused by: org.apache.drill.exec.work.foreman.ForemanException: Unexpected 
exception during fragment initialization: Internal error: Error while applying 
rule PruneScanRule:Filter_On_Scan, args 
[rel#7410:DrillFilterRel.LOGICAL.ANY([]).[](input=rel#7407:Subset#0.LOGICAL.ANY([]).[],condition=AND(=($1,
 CASE(IS NOT NULL($2), $2, '1993')), >=($3, 100))), 
rel#7423:DrillScanRel.LOGICAL.ANY([]).[](table=[dfs, 
/drill/testdata/partition_pruning/dfs/orders],groupscan=ParquetGroupScan 
[entries=[ReadEntryWithPath 
[path=maprfs:/drill/testdata/partition_pruning/dfs/orders/1994/02.parquet], 
ReadEntryWithPath 
[path=maprfs:/drill/testdata/partition_pruning/dfs/orders/1993/01.parquet], 
ReadEntryWithPath 
[path=maprfs:/drill/testdata/partition_pruning/dfs/orders/1995/03.parquet]], 
selectionRoot=maprfs:/drill/testdata/partition_pruning/dfs/orders, numFiles=3, 
columns=[`*`]])]
        ... 4 common frames omitted
Caused by: java.lang.AssertionError: Internal error: Error while applying rule 
PruneScanRule:Filter_On_Scan, args 
[rel#7410:DrillFilterRel.LOGICAL.ANY([]).[](input=rel#7407:Subset#0.LOGICAL.ANY([]).[],condition=AND(=($1,
 CASE(IS NOT NULL($2), $2, '1993')), >=($3, 100))), 
rel#7423:DrillScanRel.LOGICAL.ANY([]).[](table=[dfs, 
/drill/testdata/partition_pruning/dfs/orders],groupscan=ParquetGroupScan 
[entries=[ReadEntryWithPath 
[path=maprfs:/drill/testdata/partition_pruning/dfs/orders/1994/02.parquet], 
ReadEntryWithPath 
[path=maprfs:/drill/testdata/partition_pruning/dfs/orders/1993/01.parquet], 
ReadEntryWithPath 
[path=maprfs:/drill/testdata/partition_pruning/dfs/orders/1995/03.parquet]], 
selectionRoot=maprfs:/drill/testdata/partition_pruning/dfs/orders, numFiles=3, 
columns=[`*`]])]
        at org.apache.calcite.util.Util.newInternal(Util.java:792) 
~[calcite-core-1.4.0-drill-r5.jar:1.4.0-drill-r5]
        at 
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:251)
 ~[calcite-core-1.4.0-drill-r5.jar:1.4.0-drill-r5]
        at 
org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:808)
 ~[calcite-core-1.4.0-drill-r5.jar:1.4.0-drill-r5]
        at 
org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:303) 
~[calcite-core-1.4.0-drill-r5.jar:1.4.0-drill-r5]
        at 
org.apache.calcite.prepare.PlannerImpl.transform(PlannerImpl.java:303) 
~[calcite-core-1.4.0-drill-r5.jar:1.4.0-drill-r5]
        at 
org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.logicalPlanningVolcanoAndLopt(DefaultSqlHandler.java:545)
 ~[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToDrel(DefaultSqlHandler.java:213)
 ~[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToDrel(DefaultSqlHandler.java:248)
 ~[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.getPlan(DefaultSqlHandler.java:164)
 ~[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan(DrillSqlWorker.java:178)
 ~[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at org.apache.drill.exec.work.foreman.Foreman.runSQL(Foreman.java:905) 
[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:244) 
[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        ... 3 common frames omitted
Caused by: java.lang.AssertionError: null
        at 
org.apache.drill.exec.planner.logical.partition.FindPartitionConditions.popOpStackAndBuildFilter(FindPartitionConditions.java:188)
 ~[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.planner.logical.partition.FindPartitionConditions.analyzeCall(FindPartitionConditions.java:316)
 ~[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.planner.logical.partition.FindPartitionConditions.visitCall(FindPartitionConditions.java:241)
 ~[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.planner.logical.partition.FindPartitionConditions.visitCall(FindPartitionConditions.java:46)
 ~[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at org.apache.calcite.rex.RexCall.accept(RexCall.java:107) 
~[calcite-core-1.4.0-drill-r5.jar:1.4.0-drill-r5]
        at 
org.apache.drill.exec.planner.logical.partition.FindPartitionConditions.analyze(FindPartitionConditions.java:118)
 ~[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.planner.logical.partition.PruneScanRule.doOnMatch(PruneScanRule.java:174)
 ~[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.drill.exec.planner.logical.partition.PruneScanRule$2.onMatch(PruneScanRule.java:130)
 ~[drill-java-exec-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
        at 
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:228)
 ~[calcite-core-1.4.0-drill-r5.jar:1.4.0-drill-r5]
        ... 13 common frames omitted
{code}



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

Reply via email to