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

AssertionError when ProjectReduceExpressionsRule simplifies project expressions

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None

      Description

      When applying ProjectReduceExpressionsRule on project which expression has a non-nullable type, but after simplifying expression is null, the query fails with the assertion error:

      java.lang.AssertionError: Type mismatch:
      rel rowtype:
      RecordType(INTEGER EXPR$0) NOT NULL
      equivRel rowtype:
      RecordType(INTEGER NOT NULL EXPR$0) NOT NULL
      	at org.apache.calcite.util.Litmus$1.fail(Litmus.java:31) ~[calcite-core-1.13.0.jar:1.13.0]
      	at org.apache.calcite.plan.RelOptUtil.equal(RelOptUtil.java:1868) ~[calcite-core-1.13.0.jar:1.13.0]
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.register(VolcanoPlanner.java:855) ~[calcite-core-1.13.0.jar:1.13.0]
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.ensureRegistered(VolcanoPlanner.java:883) ~[calcite-core-1.13.0.jar:1.13.0]
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.ensureRegistered(VolcanoPlanner.java:1767) ~[calcite-core-1.13.0.jar:1.13.0]
      	at org.apache.calcite.plan.volcano.VolcanoRuleCall.transformTo(VolcanoRuleCall.java:135) ~[calcite-core-1.13.0.jar:1.13.0]
      	at org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:234) ~[calcite-core-1.13.0.jar:1.13.0]
      	at org.apache.calcite.rel.rules.ReduceExpressionsRule$ProjectReduceExpressionsRule.onMatch(ReduceExpressionsRule.java:268) ~[calcite-core-1.13.0.jar:1.13.0]
      	at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:212) ~[calcite-core-1.13.0.jar:1.13.0]
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:650) ~[calcite-core-1.13.0.jar:1.13.0]
      	at org.apache.calcite.tools.Programs$RuleSetProgram.run(Programs.java:368) ~[calcite-core-1.13.0.jar:1.13.0]
      

      The similar bug was described in CALCITE-1502, since there was a problem with non-nullable and nullable types in different case branches, but this bug appears when project expression is transformed into the expression with nullable type.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julianhyde Julian Hyde
                Reporter:
                volodymyr Vova Vysotskyi
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: