Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2200

Infinite loop for JoinPushTransitivePredicatesRule

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.15.0
    • Fix Version/s: 1.16.0
    • Component/s: core
    • Labels:
      None

      Description

      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)

        @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);
        }
      
      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)
      ...
      

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julianhyde Julian Hyde
                Reporter:
                vitalii Vitalii Diravka
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: