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

Infinite loop for JoinPushTransitivePredicatesRule

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.15.0
    • 1.16.0
    • core
    • 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

              julianhyde Julian Hyde
              vitalii Vitalii Diravka
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: