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

In JoinUnionTransposeRule rule, the string field will be converted to varchar in join, resulting in cannot address expression of different type to set

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.24.0
    • None
    • core
    • None

    Description

      original sql:select r1.deptno from (select * from hr.emps e1 union all select * from hr.emps e2) r1,
      hr.emps r2

       

       

       use CoreRules.JOIN_LEFT_UNION_TRANSPOSE rule

      used bean

       

      error log:

      java.lang.AssertionError: Cannot add expression of different type to set:
      set type is RecordType(JavaType(class java.lang.Integer) empid, VARCHAR ename, JavaType(class java.lang.Long) sal, JavaType(class java.lang.Integer) deptno, JavaType(class java.lang.Integer) empid0, JavaType(class java.lang.String) ename0, JavaType(class java.lang.Long) sal0, JavaType(class java.lang.Integer) deptno0) NOT NULL
      expression type is RecordType(JavaType(class java.lang.Integer) empid, VARCHAR ename, JavaType(class java.lang.Long) sal, JavaType(class java.lang.Integer) deptno, JavaType(class java.lang.Integer) empid0, VARCHAR ename0, JavaType(class java.lang.Long) sal0, JavaType(class java.lang.Integer) deptno0) NOT NULL
      set is rel#26:LogicalJoin.NONE.[](left=HepRelVertex#25,right=HepRelVertex#20,condition=true,joinType=inner)
      expression is LogicalUnion(all=[true])
      LogicalJoin(condition=[true], joinType=[inner])
      LogicalProject(empid=[$0], ename=[$1], sal=[$2], deptno=[$3])
      LogicalTableScan(table=[[hr, emps]])
      LogicalTableScan(table=[[hr, emps]])
      LogicalJoin(condition=[true], joinType=[inner])
      LogicalProject(empid=[$0], ename=[$1], sal=[$2], deptno=[$3])
      LogicalTableScan(table=[[hr, emps]])
      LogicalTableScan(table=[[hr, emps]])

       

      errror stack:

      at org.apache.calcite.plan.RelOptUtil.verifyTypeEquivalence(RelOptUtil.java:381) at org.apache.calcite.plan.RelOptUtil.verifyTypeEquivalence(RelOptUtil.java:381) at org.apache.calcite.plan.hep.HepRuleCall.transformTo(HepRuleCall.java:59) at org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:268) at org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:283) at org.apache.calcite.rel.rules.JoinUnionTransposeRule.onMatch(JoinUnionTransposeRule.java:115) at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:333) at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:541) at org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:406) at org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:271) at org.apache.calcite.plan.hep.HepInstruction$RuleCollection.execute(HepInstruction.java:74) at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:202) at org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:189) at com.ph.calcite.demo.TestQuery.ruleOpemiter(TestQuery.java:217) at com.ph.calcite.demo.TestQuery.testJoinQuery4(TestQuery.java:242) 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104) at org.testng.internal.Invoker.invokeMethod(Invoker.java:645) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112) at org.testng.TestRunner.privateRun(TestRunner.java:756) at org.testng.TestRunner.run(TestRunner.java:610) at org.testng.SuiteRunner.runTest(SuiteRunner.java:387) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) at org.testng.SuiteRunner.run(SuiteRunner.java:289) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293) at org.testng.TestNG.runSuitesLocally(TestNG.java:1218) at org.testng.TestNG.runSuites(TestNG.java:1133) at org.testng.TestNG.run(TestNG.java:1104) at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66) at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:110)

       

      expect:It can pass normally transformTo

      Attachments

        Activity

          People

            Unassigned Unassigned
            panh panhua
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: