You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "panhua (Jira)" <ji...@apache.org> on 2021/03/09 15:17:00 UTC

[jira] [Created] (CALCITE-4529) JoinUnionTransposeRule规则里string字段在join里会被转为varchar导致Cannot add expression of different type to set

panhua created CALCITE-4529:
-------------------------------

             Summary: JoinUnionTransposeRule规则里string字段在join里会被转为varchar导致Cannot add expression of different type to set
                 Key: CALCITE-4529
                 URL: https://issues.apache.org/jira/browse/CALCITE-4529
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.24.0
            Reporter: panhua
         Attachments: image-2021-03-09-23-10-48-118.png

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

 

 

使用CoreRules.JOIN_LEFT_UNION_TRANSPOSE规则

使用到的bean

!image-2021-03-09-23-10-48-118.png!

 

报错日志:

java.lang.AssertionError: Cannot add expression of different type to set:
set type is RecordType(JavaType(class java.lang.Integer) empid, {color:#FF0000}VARCHAR ename,{color} JavaType(class java.lang.Long) sal, JavaType(class java.lang.Integer) deptno, JavaType(class java.lang.Integer) empid0,{color:#FF0000} JavaType(class java.lang.String) ename0,{color} JavaType(class java.lang.Long) sal0, JavaType(class java.lang.Integer) deptno0) NOT NULL
expression type is RecordType(JavaType(class java.lang.Integer) empid, {color:#ff8b00}VARCHAR ename{color}, JavaType(class java.lang.Long) sal, JavaType(class java.lang.Integer) deptno, JavaType(class java.lang.Integer) empid0, {color:#ffab00}VARCHAR ename0{color}, 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]])

 

报错堆栈:

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)

 

期望:能正常transformTo



--
This message was sent by Atlassian Jira
(v8.3.4#803005)