Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-4923

Use of CASE WHEN inside a sub-query results in AssertionError

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.9.0
    • 1.13.0
    • None
    • 4 node cluster on CentOS

    Description

      Use of CASE WHEN inside a sub-query results in AssertionError

      Drill 1.9.0 git commit ID: f3c26e34
      parquet file used in test is attached

      0: jdbc:drill:schema=dfs.tmp> select * from (SELECT CASE WHEN 'WA'='WA' THEN '13' ELSE CAST(state as varchar(2)) end as state_nm from `emp_tbl` as a) `LOG_FCT` where ('WA'=`LOG_FCT`.`state_nm`);
      Error: SYSTEM ERROR: AssertionError: Type mismatch:
      rowtype of new rel:
      RecordType(CHAR(2) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL state_nm) NOT NULL
      rowtype of set:
      RecordType(VARCHAR(2) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" state_nm) NOT NULL
      
      
      [Error Id: 59b8da55-cf01-41fe-ba7a-018f7fad2892 on centos-01.qa.lab:31010] (state=,code=0)
      

      Stack trace from drillbit.log

      2016-10-03 09:37:32,756 [280dd922-b97d-2ccd-551c-e425c075d91f:foreman] ERROR o.a.drill.exec.work.foreman.Foreman - SYSTEM ERROR: AssertionError: Type mismatch:
      rowtype of new rel:
      RecordType(CHAR(2) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL state_nm) NOT NULL
      rowtype of set:
      RecordType(VARCHAR(2) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" state_nm) NOT NULL
      
      
      [Error Id: 59b8da55-cf01-41fe-ba7a-018f7fad2892 on centos-01.qa.lab:31010]
      org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: AssertionError: Type mismatch:
      rowtype of new rel:
      RecordType(CHAR(2) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL state_nm) NOT NULL
      rowtype of set:
      RecordType(VARCHAR(2) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" state_nm) NOT NULL
      
      
      [Error Id: 59b8da55-cf01-41fe-ba7a-018f7fad2892 on centos-01.qa.lab:31010]
              at org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) ~[drill-common-1.9.0-SNAPSHOT.jar:1.9.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman$ForemanResult.close(Foreman.java:825) [drill-java-exec-1.9.0-SNAPSHOT.jar:1.9.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman.moveToState(Foreman.java:935) [drill-java-exec-1.9.0-SNAPSHOT.jar:1.9.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:281) [drill-java-exec-1.9.0-SNAPSHOT.jar:1.9.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: Internal error: Error while applying rule ProjectMergeRule:force_mode, args [rel#11115:LogicalProject.NONE.ANY([]).[](input=rel#11103:Subset#6.NONE.ANY([]).[],state_nm='13'), rel#11107:LogicalProject.NONE.ANY([]).[](input=rel#11095:Subset#4.NONE.ANY([]).[],state=$1)]
              ... 4 common frames omitted
      Caused by: java.lang.AssertionError: Internal error: Error while applying rule ProjectMergeRule:force_mode, args [rel#11115:LogicalProject.NONE.ANY([]).[](input=rel#11103:Subset#6.NONE.ANY([]).[],state_nm='13'), rel#11107:LogicalProject.NONE.ANY([]).[](input=rel#11095:Subset#4.NONE.ANY([]).[],state=$1)]
              at org.apache.calcite.util.Util.newInternal(Util.java:792) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:251) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:808) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:303) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.transform(DefaultSqlHandler.java:404) ~[drill-java-exec-1.9.0-SNAPSHOT.jar:1.9.0-SNAPSHOT]
              at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.transform(DefaultSqlHandler.java:343) ~[drill-java-exec-1.9.0-SNAPSHOT.jar:1.9.0-SNAPSHOT]
              at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToDrel(DefaultSqlHandler.java:240) ~[drill-java-exec-1.9.0-SNAPSHOT.jar:1.9.0-SNAPSHOT]
              at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToDrel(DefaultSqlHandler.java:290) ~[drill-java-exec-1.9.0-SNAPSHOT.jar:1.9.0-SNAPSHOT]
              at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.getPlan(DefaultSqlHandler.java:168) ~[drill-java-exec-1.9.0-SNAPSHOT.jar:1.9.0-SNAPSHOT]
              at org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan(DrillSqlWorker.java:94) ~[drill-java-exec-1.9.0-SNAPSHOT.jar:1.9.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman.runSQL(Foreman.java:1008) [drill-java-exec-1.9.0-SNAPSHOT.jar:1.9.0-SNAPSHOT]
              at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:264) [drill-java-exec-1.9.0-SNAPSHOT.jar:1.9.0-SNAPSHOT]
              ... 3 common frames omitted
      Caused by: java.lang.AssertionError: Internal error: Error occurred while applying rule ProjectMergeRule:force_mode
              at org.apache.calcite.util.Util.newInternal(Util.java:792) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.volcano.VolcanoRuleCall.transformTo(VolcanoRuleCall.java:150) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:213) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.rel.rules.ProjectMergeRule.onMatch(ProjectMergeRule.java:118) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:228) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              ... 13 common frames omitted
      Caused by: java.lang.AssertionError: Type mismatch:
      rowtype of new rel:
      RecordType(CHAR(2) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL state_nm) NOT NULL
      rowtype of set:
      RecordType(VARCHAR(2) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" state_nm) NOT NULL
              at org.apache.calcite.plan.RelOptUtil.equal(RelOptUtil.java:1696) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.volcano.RelSubset.add(RelSubset.java:295) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.volcano.RelSet.add(RelSet.java:147) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.volcano.VolcanoPlanner.addRelToSet(VolcanoPlanner.java:1818) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.volcano.VolcanoPlanner.registerImpl(VolcanoPlanner.java:1760) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.volcano.VolcanoPlanner.register(VolcanoPlanner.java:1017) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.volcano.VolcanoPlanner.ensureRegistered(VolcanoPlanner.java:1037) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.volcano.VolcanoPlanner.ensureRegistered(VolcanoPlanner.java:1940) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              at org.apache.calcite.plan.volcano.VolcanoRuleCall.transformTo(VolcanoRuleCall.java:138) ~[calcite-core-1.4.0-drill-r17.jar:1.4.0-drill-r17]
              ... 16 common frames omitted
      

      explain plan did not return any result.

      0: jdbc:drill:schema=dfs.tmp> explain plan for select * from (SELECT CASE WHEN 'WA'='WA' THEN '13' ELSE CAST(state as varchar(2)) end as state_nm from `emp_tbl` as a) `LOG_FCT` where ('WA'=`LOG_FCT`.`state_nm`);
      Error: SYSTEM ERROR: AssertionError: Type mismatch:
      rowtype of new rel:
      RecordType(CHAR(2) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL state_nm) NOT NULL
      rowtype of set:
      RecordType(VARCHAR(2) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" state_nm) NOT NULL
      
      
      [Error Id: 65312464-609a-4839-8ed2-374bab63646c on centos-01.qa.lab:31010] (state=,code=0)
      

      Attachments

        1. 0_0_0.parquet
          1 kB
          Khurram Faraaz

        Issue Links

          Activity

            People

              sharnyk Serhii Harnyk
              khfaraaz Khurram Faraaz
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: