Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1649

Data type mismatch in EnumerableMergeJoin

    XMLWordPrintableJSON

Details

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

    Description

      In plans that use EnumerableMergeJoin, if the keys have different types you can get a runtime exception. After the fix for CALCITE-1634 one particular query in sub-query.iq stopped using EnumerableSemiJoin and started using EnumerableMergeJoin (following the realization that a single-row Values was trivially sorted):

      with t (a, b) as (select * from (values (60, 'b')))
      select * from t where a in (select deptno from "scott".dept);
      EnumerableCalc(expr#0..2=[{inputs}], A=[$t1], B=[$t2])
        EnumerableMergeJoin(condition=[=($0, $1)], joinType=[inner])
          EnumerableCalc(expr#0..2=[{inputs}], DEPTNO=[$t0])
            EnumerableTableScan(table=[[scott, DEPT]])
          EnumerableValues(tuples=[[{ 60, 'b' }]])
      !plan
      java.sql.SQLException: Error while executing SQL "with t (a, b) as (select * from (values (60, 'b')))
      select * from t where a in (select deptno from "scott".dept)
      ": java.lang.Integer cannot be cast to java.lang.Byte
      	at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
      	at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
      	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
      	at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218)
      	at net.hydromatic.quidem.Quidem$CheckResultCommand.execute(Quidem.java:830)
      	at net.hydromatic.quidem.Quidem$CompositeCommand.execute(Quidem.java:1450)
      	at net.hydromatic.quidem.Quidem.execute(Quidem.java:197)
      	at org.apache.calcite.test.QuidemTest.checkRun(QuidemTest.java:165)
      	at org.apache.calcite.test.QuidemTest.testSqlDummy(QuidemTest.java:246)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.apache.calcite.test.QuidemTest.test(QuidemTest.java:215)
      	at org.apache.calcite.test.QuidemTest.main(QuidemTest.java:80)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
      Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Byte
      	at java.lang.Byte.compareTo(Byte.java:44)
      	at org.apache.calcite.linq4j.EnumerableDefaults$MergeJoinEnumerator.advance(EnumerableDefaults.java:3257)
      	at org.apache.calcite.linq4j.EnumerableDefaults$MergeJoinEnumerator.start(EnumerableDefaults.java:3242)
      	at org.apache.calcite.linq4j.EnumerableDefaults$MergeJoinEnumerator.<init>(EnumerableDefaults.java:3236)
      	at org.apache.calcite.linq4j.EnumerableDefaults$13.enumerator(EnumerableDefaults.java:1406)
      	at Baz$5$1.<init>(Unknown Source)
      	at Baz$5.enumerator(Unknown Source)
      	at org.apache.calcite.linq4j.AbstractEnumerable.iterator(AbstractEnumerable.java:33)
      

      Attachments

        Activity

          People

            julianhyde Julian Hyde
            julianhyde Julian Hyde
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: