kate created CALCITE-6501:
-----------------------------

             Summary: Assertion Error in JoinUnifyRule Due to Type Mismatch
                 Key: CALCITE-6501
                 URL: https://issues.apache.org/jira/browse/CALCITE-6501
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: kate


In some cases, there is an assertion failure during the unifyRule rewriting 
process due to a type mismatch. If we can't rewrite it, we'd better return null 
instead of assert.

example:
{code:java}
@Test
public void testJoinOnCalcToJoin3011()
{
  String mv = ""
      + "select \"emps\".\"empid\", \"emps\".\"deptno\", \"depts\".\"deptno\" 
from\n"
      + "\"emps\" right join \"depts\"\n"
      + "on \"emps\".\"deptno\" = \"depts\".\"deptno\"";
  String query = ""
      + "select \"A\".\"empid\", \"A\".\"a\", \"A\".\"deptno\", 
\"depts\".\"deptno\" from\n"
      + " (select \"empid\", \"deptno\", \"deptno\" \"a\" from \"emps\") A"
      + " right join \"depts\"\n"
      + "on \"A\".\"deptno\" = \"depts\".\"deptno\"";
  sql(mv, query).noMat();
} {code}
Trace:
{code:java}
type mismatch:type1:JavaType(int) NOT NULLtype2:JavaType(class 
java.lang.Integer)java.lang.AssertionError: type mismatch:type1:JavaType(int) 
NOT NULLtype2:JavaType(class java.lang.Integer) at 
org.apache.calcite.util.Litmus.lambda$static$0(Litmus.java:31) at 
org.apache.calcite.plan.RelOptUtil.eq(RelOptUtil.java:2204) at 
org.apache.calcite.rex.RexProgramBuilder$RegisterInputShuttle.visitInputRef(RexProgramBuilder.java:949)
 at 
org.apache.calcite.rex.RexProgramBuilder$RegisterInputShuttle.visitInputRef(RexProgramBuilder.java:927)
 at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:125) at 
org.apache.calcite.rex.RexProgramBuilder.registerInput(RexProgramBuilder.java:303)
 at 
org.apache.calcite.rex.RexProgramBuilder.addProject(RexProgramBuilder.java:213) 
at org.apache.calcite.rex.RexProgram.create(RexProgram.java:235) at 
org.apache.calcite.rex.RexProgram.create(RexProgram.java:204) at 
org.apache.calcite.plan.SubstitutionVisitor$JoinOnLeftCalcToJoinUnifyRule.apply(SubstitutionVisitor.java:1265)
 at 
org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:589) at 
org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:523) at 
org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest$1.optimize(MaterializedViewSubstitutionVisitorTest.java:88)
 at 
org.apache.calcite.test.MaterializedViewTester.checkNoMaterialize(MaterializedViewTester.java:94)
 at 
org.apache.calcite.test.MaterializedViewFixture.noMat(MaterializedViewFixture.java:60)
 at {code}
 

 

 
 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to