You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "junheleo (Jira)" <ji...@apache.org> on 2023/05/08 03:48:00 UTC
[jira] [Commented] (CALCITE-5689) Materialized view rewrite failed when the project field is on the nullable side of the join using JoinOnCalcsToJoinUnifyRule
[ https://issues.apache.org/jira/browse/CALCITE-5689?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17720382#comment-17720382 ]
junheleo commented on CALCITE-5689:
-----------------------------------
[~jinxing6042@126.com] Could you please help confirm whether the above scenario is an problem?
> Materialized view rewrite failed when the project field is on the nullable side of the join using JoinOnCalcsToJoinUnifyRule
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-5689
> URL: https://issues.apache.org/jira/browse/CALCITE-5689
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.34.0
> Reporter: junheleo
> Priority: Minor
>
> As shown in the following example:
> {code:java}
> String mv = ""
> + "select * from\n"
> + " (select * from \"emps\") \"A\"\n"
> + " left join\n"
> + " (select \"deptno\",\"name\" from \"depts\") \"B\"\n"
> + " on \"A\".\"deptno\" = \"B\".\"deptno\"";
> String query = ""
> + "select \"A\".\"deptno\",\"B\".\"deptno\" from\n"
> + " (select \"deptno\" from \"emps\") \"A\"\n"
> + " left join\n"
> + " (select \"deptno\" from \"depts\" ) \"B\"\n"
> + " on \"A\".\"deptno\" = \"B\".\"deptno\"";
> sql(mv, query).ok(); {code}
> It failed with the following messages:
> {code:java}
> java.lang.AssertionError: type mismatch:
> type1:
> JavaType(int) NOT NULL
> type2:
> JavaType(class java.lang.Integer) at org.apache.calcite.util.Litmus$1.fail(Litmus.java:32)
> at org.apache.calcite.plan.RelOptUtil.eq(RelOptUtil.java:2211)
> at org.apache.calcite.rex.RexProgramBuilder$RegisterInputShuttle.visitInputRef(RexProgramBuilder.java:953)
> at org.apache.calcite.rex.RexProgramBuilder$RegisterInputShuttle.visitInputRef(RexProgramBuilder.java:931)
> at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:114)
> at org.apache.calcite.rex.RexProgramBuilder.registerInput(RexProgramBuilder.java:302)
> at org.apache.calcite.rex.RexProgramBuilder.addProject(RexProgramBuilder.java:212)
> 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$JoinOnCalcsToJoinUnifyRule.apply(SubstitutionVisitor.java:1446)
> at org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:585)
> at org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:519)
> at org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest$1.optimize(MaterializedViewSubstitutionVisitorTest.java:94)
> at org.apache.calcite.test.MaterializedViewTester.checkMaterialize(MaterializedViewTester.java:78)
> at org.apache.calcite.test.MaterializedViewFixture.ok(MaterializedViewFixture.java:56)
> at org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest.testJoinOnRightProjectToJoin(MaterializedViewSubstitutionVisitorTest.java:775){code}
> Field B.deptno is considered non-null in the join input but becomes nullable after the join, resulting in a type mismatch.
> Similar cases also occur in JoinOnRightCalcToJoinUnifyRule and JoinOnLeftCalcToJoinUnifyRule
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)