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

Haisheng Yuan commented on CALCITE-2893:
----------------------------------------

I did some RCA, I believe the reason is as follows:
the table function's return row type is BIGINT NOT NULL. So in the join 
condition, the type of right operand (n) is BIGINT NOT NULL. But after left 
join, the right operand becomes nullable BIGINT. In SqlToRelConverter.java, we 
create a filter on top of LogicalCorrelate, the right operand of join condition 
still expects BIGINT NOT NULL, thus we hit an assertion error.

> Type mismatch assertion error when creating join condition
> ----------------------------------------------------------
>
>                 Key: CALCITE-2893
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2893
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Haisheng Yuan
>            Priority: Major
>
> Repro:
> in TableFunctionTest.java, add the following test case:
> {code:java}
> @Test public void testValuesLateralJoin() {
>     final String q1 = "select *\n"
>         + "from (values 4) as t (c)\n"
>         + "left join lateral table(\"s\".\"fibonacci2\"(c)) as R(n) on c=n";
>       with()
>           .with(CalciteConnectionProperty.CONFORMANCE,
>               SqlConformanceEnum.LENIENT)
>           .query(q1)
>           .returnsUnordered("C=4; N=null");
>   }
> {code}
> Error message:
> {code:java}
> java.lang.AssertionError: type mismatch:
> ref:
> BIGINT NOT NULL
> input:
> BIGINT
>       at org.apache.calcite.util.Litmus$1.fail(Litmus.java:31)
>       at org.apache.calcite.plan.RelOptUtil.eq(RelOptUtil.java:1832)
>       at org.apache.calcite.rex.RexChecker.visitInputRef(RexChecker.java:125)
>       at org.apache.calcite.rex.RexChecker.visitInputRef(RexChecker.java:57)
>       at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:112)
>       at org.apache.calcite.rex.RexChecker.visitCall(RexChecker.java:140)
>       at org.apache.calcite.rex.RexChecker.visitCall(RexChecker.java:57)
>       at org.apache.calcite.rex.RexCall.accept(RexCall.java:190)
>       at org.apache.calcite.rel.core.Filter.isValid(Filter.java:120)
>       at 
> org.apache.calcite.rel.logical.LogicalFilter.<init>(LogicalFilter.java:70)
>       at 
> org.apache.calcite.rel.logical.LogicalFilter.create(LogicalFilter.java:114)
>       at 
> org.apache.calcite.rel.logical.LogicalFilter.create(LogicalFilter.java:101)
>       at 
> org.apache.calcite.rel.core.RelFactories$FilterFactoryImpl.createFilter(RelFactories.java:295)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.createJoin(SqlToRelConverter.java:2413)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2065)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:644)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:625)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3080)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:561)
> {code}
> Even literal is definitely not null, we should still be able to compare the 
> two.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to