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

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

[~asolimando] Yes, I agree that we shouldn't be discussing this together. For 
the Assert part, I think we should return null before the assert occurs, for 
the case above, the root cause is the mismatch of the null value, and if one 
wishes to avoid this, the approach can be to reject the Right Join in 
JoinOnLeftCalcToJoin, and to reject the Right Join in JoinOnRIghtCalcToJoin 
rejects Left Join. Of course, this would be a missed opportunity for some 
rewrites, even if it is rewritable.

> 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