[
https://issues.apache.org/jira/browse/CALCITE-2205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16389485#comment-16389485
]
Vitalii Diravka commented on CALCITE-2205:
------------------------------------------
[~julianhyde] Thank you for review.
I think rexNode in my case is simple as much as possible and solution for
CALCITE-1995 works good. But the predicates RexNode from my case is not always
true or false.
Without my changes LogicalFilter will be created infinitely and then will be
wrapped with a new HepRelVertex, since planner decides that rule transforms a
RelNode to a new one:
{code}
LogicalFilter(condition=[OR(IS NOT NULL($5), =($5, 4))])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4],
SAL=[$5], COMM=[$6], SLACKER=[$8])
LogicalFilter(condition=[AND(=($7, 20), >($5, 1000))])
LogicalTableScan(table=[[CATALOG, SALES, EMPNULLABLES]])
LogicalFilter(condition=[OR(IS NOT NULL($5), =($5, 4))])
LogicalFilter(condition=[OR(IS NOT NULL($5), =($5, 4))])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4],
SAL=[$5], COMM=[$6], SLACKER=[$8])
LogicalFilter(condition=[AND(=($7, 20), >($5, 1000))])
LogicalTableScan(table=[[CATALOG, SALES, EMPNULLABLES]])
LogicalFilter(condition=[OR(IS NOT NULL($5), =($5, 4))])
LogicalFilter(condition=[OR(IS NOT NULL($5), =($5, 4))])
LogicalFilter(condition=[OR(IS NOT NULL($5), =($5, 4))])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4],
SAL=[$5], COMM=[$6], SLACKER=[$8])
LogicalFilter(condition=[AND(=($7, 20), >($5, 1000))])
LogicalTableScan(table=[[CATALOG, SALES, EMPNULLABLES]])
LogicalFilter(condition=[OR(IS NOT NULL($5), =($5, 4))])
LogicalFilter(condition=[OR(IS NOT NULL($5), =($5, 4))])
LogicalFilter(condition=[OR(IS NOT NULL($5), =($5, 4))])
LogicalFilter(condition=[OR(IS NOT NULL($5), =($5, 4))])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3],
HIREDATE=[$4], SAL=[$5], COMM=[$6], SLACKER=[$8])
LogicalFilter(condition=[AND(=($7, 20), >($5, 1000))])
LogicalTableScan(table=[[CATALOG, SALES, EMPNULLABLES]])
{code}
I see two ways to resolve it: one to simplify RelNode after obtaining this
double-filter, the other way do not create a new filter if the last one is the
same. I prefer last way, but the input relNode for RelBuilder#filter is
RelHepVertex.
Please let me know, if some mechanism to resolve this issue is already exists
in Calcite and I should use it.
> One more Infinite loop for JoinPushTransitivePredicatesRule
> -----------------------------------------------------------
>
> Key: CALCITE-2205
> URL: https://issues.apache.org/jira/browse/CALCITE-2205
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.15.0
> Reporter: Vitalii Diravka
> Assignee: Julian Hyde
> Priority: Major
> Fix For: 1.16.0
>
>
> CALCITE-2200 resolves some cases of infinite loop via stopping of recursion
> in HepPlanner#applyRules, when newVertex is the same as vertex.
> In this jira one more case of infinite loop is described:
> JoinPushTransitivePredicatesRule#onMatch generates new right or left inputs
> via using RelBuilder#filter method on top of LogicalFilter RelNode with the
> same condition.
> In this case a new RelNode shouldn't be created. Possible fix to change logic
> of RelBuilder#filter method.
> TestCase for reproduce:
> {code}
> @Test public void testJoinPushTransitivePredicatesRule2() {
> HepProgramBuilder builder = new HepProgramBuilder();
> builder.addRuleInstance(JoinPushTransitivePredicatesRule.INSTANCE);
> HepProgram build = builder.build();
> HepPlanner hepPlanner = new HepPlanner(build);
> final String sql = "select n1.SAL from EMPNULLABLES_20 n1 where n1.SAL\n"
> + "IN (select n2.SAL from EMPNULLABLES_20 n2 "
> + "where n1.SAL = n2.SAL or n1.SAL = 4)";
> sql(sql)
> .withDecorrelation(true)
> .with(hepPlanner)
> .check();
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)