Vitalii Diravka created CALCITE-2200:
----------------------------------------

             Summary: Infinite loop for JoinPushTransitivePredicatesRule
                 Key: CALCITE-2200
                 URL: https://issues.apache.org/jira/browse/CALCITE-2200
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.15.0
            Reporter: Vitalii Diravka
            Assignee: Julian Hyde
             Fix For: next


Infinite loop is obtained while using FilterIntoJoinRule + 
JoinPushTransitivePredicatesRule in HEP planner for some correlated queries, 
for instance:
select d.deptno from sales.emp d where d.deptno IN (select e.deptno from 
sales.emp e where e.deptno = d.deptno or e.deptno = 4)

{code}
  @Test public void testJoinPushTransitivePredicatesRule() {
    HepProgram preProgram = new HepProgramBuilder()
        .addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
        .addRuleInstance(FilterJoinRule.JOIN)
        .addRuleInstance(JoinPushTransitivePredicatesRule.INSTANCE)
        .build();

    HepProgramBuilder builder = new HepProgramBuilder();
    HepPlanner hepPlanner = new HepPlanner(builder.build());

    final String sql = "select d.deptno from sales.emp d where d.deptno\n"
        + "IN (select e.deptno from sales.emp e "
        + "where e.deptno = d.deptno or e.deptno = 4)";
    TesterImpl tester = new TesterImpl(getDiffRepos(), true, false, true, 
false, null, null);
    checkPlanning(tester, preProgram, hepPlanner, sql);
  }
{code}

{code}
java.lang.StackOverflowError
        at 
org.apache.calcite.util.mapping.Mappings$PartialFunctionImpl.<init>(Mappings.java:1568)
        at org.apache.calcite.util.mapping.Mappings.create(Mappings.java:76)
        at 
org.apache.calcite.rel.metadata.RelMdPredicates.getPredicates(RelMdPredicates.java:185)
        at GeneratedMetadataHandler_Predicates.getPredicates_$(Unknown Source)
        at GeneratedMetadataHandler_Predicates.getPredicates(Unknown Source)
        at GeneratedMetadataHandler_Predicates.getPredicates_$(Unknown Source)
        at GeneratedMetadataHandler_Predicates.getPredicates(Unknown Source)
        at 
org.apache.calcite.rel.metadata.RelMetadataQuery.getPulledUpPredicates(RelMetadataQuery.java:802)
        at 
org.apache.calcite.rel.metadata.RelMdPredicates.getPredicates(RelMdPredicates.java:344)
        at GeneratedMetadataHandler_Predicates.getPredicates_$(Unknown Source)
        at GeneratedMetadataHandler_Predicates.getPredicates(Unknown Source)
        at GeneratedMetadataHandler_Predicates.getPredicates_$(Unknown Source)
        at GeneratedMetadataHandler_Predicates.getPredicates(Unknown Source)
        at 
org.apache.calcite.rel.metadata.RelMetadataQuery.getPulledUpPredicates(RelMetadataQuery.java:802)
        at 
org.apache.calcite.rel.metadata.RelMdPredicates.getPredicates(RelMdPredicates.java:318)
        at GeneratedMetadataHandler_Predicates.getPredicates_$(Unknown Source)
...
{code}

Note1: for the same query, but with AND operator the rule works fine.
Note2: the rile works also after firing JoinToCorrelateRule rule.



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

Reply via email to