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

Query fails with AssertionError when joining persistent and temporary tables

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.12.0
    • 1.14.0
    • None

    Description

      Problem description
      When joining persistent and temporary tables:

      create TEMPORARY table temp_tab as select '12312' as c2;
      create table pers_tab as select '12312' as c1;
      select * from `%s` a join `%s` b on a.c1 = b.c2
      

      Query fails with AssertionError:

      [Error Id: 85663e83-d7f0-4f84-92ea-fb329e31aec5 on user515050-pc:31013]
      org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: AssertionError: Field ordinal 1 is invalid for  type '(DrillRecordRow[**])'
      
      
      [Error Id: 85663e83-d7f0-4f84-92ea-fb329e31aec5 on user515050-pc:31013]
      	at org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:633) ~[classes/:na]
      	at org.apache.drill.exec.work.foreman.Foreman$ForemanResult.close(Foreman.java:761) [classes/:na]
      	at org.apache.drill.exec.work.foreman.QueryStateProcessor.checkCommonStates(QueryStateProcessor.java:325) [classes/:na]
      	at org.apache.drill.exec.work.foreman.QueryStateProcessor.planning(QueryStateProcessor.java:221) [classes/:na]
      	at org.apache.drill.exec.work.foreman.QueryStateProcessor.moveToState(QueryStateProcessor.java:83) [classes/:na]
      	at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:293) [classes/:na]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_171]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_171]
      	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
      Caused by: org.apache.drill.exec.work.foreman.ForemanException: Unexpected exception during fragment initialization: while converting CAST(`a`.`colA2` AS VARCHAR) = CAST(`b`.`colB2` AS VARCHAR)
      	at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:294) [classes/:na]
      	... 3 common frames omitted
      Caused by: java.lang.RuntimeException: while converting CAST(`a`.`colA2` AS VARCHAR) = CAST(`b`.`colB2` AS VARCHAR)
      	at org.apache.calcite.sql2rel.ReflectiveConvertletTable$1.convertCall(ReflectiveConvertletTable.java:90) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlNodeToRexConverterImpl.convertCall(SqlNodeToRexConverterImpl.java:63) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4656) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:3994) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4558) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertJoinCondition(SqlToRelConverter.java:2601) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2048) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:643) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:624) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3058) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:560) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.drill.exec.planner.sql.SqlConverter.toRel(SqlConverter.java:384) ~[classes/:na]
      	at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToRel(DefaultSqlHandler.java:664) ~[classes/:na]
      	at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.validateAndConvert(DefaultSqlHandler.java:207) ~[classes/:na]
      	at org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.getPlan(DefaultSqlHandler.java:176) ~[classes/:na]
      	at org.apache.drill.exec.planner.sql.DrillSqlWorker.getQueryPlan(DrillSqlWorker.java:145) ~[classes/:na]
      	at org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan(DrillSqlWorker.java:83) ~[classes/:na]
      	at org.apache.drill.exec.work.foreman.Foreman.runSQL(Foreman.java:567) [classes/:na]
      	at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:266) [classes/:na]
      	... 3 common frames omitted
      Caused by: java.lang.reflect.InvocationTargetException: null
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
      	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
      	at org.apache.calcite.sql2rel.ReflectiveConvertletTable$1.convertCall(ReflectiveConvertletTable.java:87) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	... 22 common frames omitted
      Caused by: java.lang.AssertionError: Field ordinal 1 is invalid for  type '(DrillRecordRow[**])'
      	at org.apache.calcite.rex.RexBuilder.makeFieldAccess(RexBuilder.java:195) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertIdentifier(SqlToRelConverter.java:3623) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter.access$2200(SqlToRelConverter.java:214) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4665) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:3994) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql.SqlIdentifier.accept(SqlIdentifier.java:344) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4558) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.StandardConvertletTable.convertCast(StandardConvertletTable.java:573) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.StandardConvertletTable$1.convertCall(StandardConvertletTable.java:116) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlNodeToRexConverterImpl.convertCall(SqlNodeToRexConverterImpl.java:63) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4656) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:3994) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:4558) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.StandardConvertletTable.convertExpressionList(StandardConvertletTable.java:857) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.StandardConvertletTable.convertCall(StandardConvertletTable.java:833) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	at org.apache.calcite.sql2rel.StandardConvertletTable.convertCall(StandardConvertletTable.java:817) ~[calcite-core-1.16.0-drill-r6.jar:1.16.0-drill-r6]
      	... 27 common frames omitted
      16:42:17.217 [main] ERROR org.apache.drill.TestReporter - Test Failed (d: 0 B(1 B), h: -106.7 MiB(97.8 MiB), nh: 19.5 MiB(78.7 MiB)): testTempTab(org.apache.drill.exec.vector.complex.writer.TestJsonReader)
      org.apache.drill.common.exceptions.UserRemoteException: SYSTEM ERROR: AssertionError: Field ordinal 1 is invalid for  type '(DrillRecordRow[**])'
      

      Root cause
      This bug appeared after rebasing Calcite from 1.4.0 to 1.13.0.
      With new changes, a temporary schema was passed into SqlIdentifier asĀ an array with a string that corresponds to the schema path but was expected that every element of the schema path will be represented as a separate string.

      It caused the loss of previously preserved row type, so the error is thrown.

      Attachments

        Issue Links

          Activity

            People

              volodymyr Vova Vysotskyi
              volodymyr Vova Vysotskyi
              Arina Ielchiieva Arina Ielchiieva
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: