[
https://issues.apache.org/jira/browse/CALCITE-6439?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17855454#comment-17855454
]
Julian Hyde commented on CALCITE-6439:
--------------------------------------
There should be existing code that converts {{WHERE NULL}} to {{WHERE FALSE}}.
If there isn't, you should fix {{RelBuilder.filter}} and add a test to
{{RelBuilderTest}}. {{Filter.isValid}} should check that the condition is of
type {{BOOLEAN}}, and the {{AND}}, {{OR}}, {{NOT}} operators should do the same
of their arguments.
> FILTER_INSTANCE in RelOptRule does not take effect
> --------------------------------------------------
>
> Key: CALCITE-6439
> URL: https://issues.apache.org/jira/browse/CALCITE-6439
> Project: Calcite
> Issue Type: Wish
> Components: core
> Affects Versions: 1.37.0
> Reporter: Caican Cai
> Priority: Minor
> Fix For: 1.38.0
>
>
> test example
> {code:java}
> @Test void testFilterNull() {
> final String sql = "select * from emp where null";
> sql(sql).withRule(PruneEmptyRules.FILTER_INSTANCE).check();
> } {code}
> logical plan
> {code:java}
> </Resource>
> </TestCase>
> <TestCase name="testFilterNull">
> <Resource name="sql">
> <![CDATA[select * from emp where null]]>
> </Resource>
> <Resource name="planBefore">
> <![CDATA[
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4],
> SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
> LogicalFilter(condition=[null:BOOLEAN])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> ]]>
> </Resource>
> <Resource name="planAfter">
> <![CDATA[
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4],
> SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
> LogicalFilter(condition=[null:BOOLEAN])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> ]]>{code}
> unchanged.
> The logical plan that should be generated after optimization
> {code:java}
> LogicalValues(tuples=[[]]){code}
> or
> {code:java}
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4],
> SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
> LogicalValues(tuples=[[]]) {code} {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)