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

Prune of empty values causes assertion error "rel cost is lower than best cost"

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.18.0
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None

      Description

      Prune of empty values causes assertion error "rel cost is lower than best cost".

      values(1)
       union all values(2)
       union all select * from (values(3)) where false

      it is parsed as

      LogicalUnion(all=[true])
        LogicalUnion(all=[true])
          LogicalValues(tuples=[[{ 1 }]])
          LogicalProject(EXPR$0=[$0])
            LogicalFilter(condition=[false])
              LogicalValues(tuples=[[{ 3 }]])
        LogicalValues(tuples=[[{ 2 }]])

      Then it fails as follows:

      java.lang.AssertionError: rel [rel#69:EnumerableUnion.ENUMERABLE.[](input#0=RelSubset#78,input#1=RelSubset#71,all=true)] has lower cost {4.0 rows, 4.0 cpu, 0.0 io} than best cost {5.0 rows, 5.0 cpu, 0.0 io} of subset [rel#67:Subset#6.ENUMERABLE.[]]
      
      	at org.apache.calcite.util.Litmus$1.fail(Litmus.java:31)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.isValid(VolcanoPlanner.java:896)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.register(VolcanoPlanner.java:859)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.ensureRegistered(VolcanoPlanner.java:876)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.ensureRegistered(VolcanoPlanner.java:1747)
      	at org.apache.calcite.plan.volcano.VolcanoRuleCall.transformTo(VolcanoRuleCall.java:136)
      	at org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:236)
      	at org.apache.calcite.rel.convert.ConverterRule.onMatch(ConverterRule.java:141)
      	at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:213)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:641)
      	at org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:339)
      	at org.apache.calcite.prepare.PlannerImpl.transform(PlannerImpl.java:349)
      	at org.apache.calcite.tools.PlannerTest.checkUnionPruning(PlannerTest.java:465)
      	at org.apache.calcite.tools.PlannerTest.emptyUnions32(PlannerTest.java:436)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                vladimirsitnikov Vladimir Sitnikov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: