[ 
https://issues.apache.org/jira/browse/CALCITE-6501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17868620#comment-17868620
 ] 

kate commented on CALCITE-6501:
-------------------------------

This is because the left input field of the Right Join will be Nullable after 
the Join operator, but we didn't take this into account when we add the Calc 
Project, so maybe we need to intercept this situation in the Join UnifyRule.

Of course, if we need to go into more detail, we can do CAST on the allowed 
case type.In that case, we should consider more details

> 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
>            Priority: Minor
>
> 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