You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Stamatis Zampetakis (Jira)" <ji...@apache.org> on 2026/03/13 13:34:00 UTC
[jira] [Created] (CALCITE-7441) AggregateFilterToFilteredAggregateRule fails when WHERE clause is nullable
Stamatis Zampetakis created CALCITE-7441:
--------------------------------------------
Summary: AggregateFilterToFilteredAggregateRule fails when WHERE clause is nullable
Key: CALCITE-7441
URL: https://issues.apache.org/jira/browse/CALCITE-7441
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.42.0
Reporter: Stamatis Zampetakis
Assignee: Stamatis Zampetakis
Fix For: 1.42.0
The {{AggregateFilterToFilteredAggregateRule}} fails when the condition in the WHERE clause is nullable. Consider, the following SQL query and assume that column {{mgr}} is nullable.
{code:sql}
select sum(sal) from emp where mgr = 10
{code}
It's easy to see that the condition {{mgr = 10}} is nullable when the respective column is nullable. The plan for the query is shown below:
{noformat}
LogicalAggregate(group=[{}], EXPR$0=[SUM($5)])
LogicalFilter(condition=[=($3, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
{noformat}
Applying the rule, on this query fails with the following stacktrace:
{noformat}
java.lang.IllegalArgumentException: filter must be BOOLEAN NOT NULL
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:141)
at org.apache.calcite.rel.core.Aggregate.<init>(Aggregate.java:178)
at org.apache.calcite.rel.logical.LogicalAggregate.<init>(LogicalAggregate.java:72)
at org.apache.calcite.rel.logical.LogicalAggregate.create_(LogicalAggregate.java:144)
at org.apache.calcite.rel.logical.LogicalAggregate.create(LogicalAggregate.java:116)
at org.apache.calcite.rel.core.RelFactories$AggregateFactoryImpl.createAggregate(RelFactories.java:346)
at org.apache.calcite.tools.RelBuilder.aggregate_(RelBuilder.java:2786)
at org.apache.calcite.tools.RelBuilder.pruneAggregateInputFieldsAndDeduplicateAggCalls(RelBuilder.java:2657)
at org.apache.calcite.tools.RelBuilder.aggregate_(RelBuilder.java:2581)
at org.apache.calcite.tools.RelBuilder.aggregate(RelBuilder.java:2478)
at org.apache.calcite.rel.rules.AggregateFilterToFilteredAggregateRule.onMatch(AggregateFilterToFilteredAggregateRule.java:94)
at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:350)
at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:575)
at org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:459)
at org.apache.calcite.plan.hep.HepPlanner.executeRuleInstance(HepPlanner.java:282)
at org.apache.calcite.plan.hep.HepInstruction$RuleInstance$State.execute(HepInstruction.java:178)
at org.apache.calcite.plan.hep.HepPlanner.lambda$executeProgram$0(HepPlanner.java:250)
at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:421)
at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:249)
at org.apache.calcite.plan.hep.HepProgram$State.execute(HepProgram.java:118)
at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:244)
at org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:219)
{noformat}
When creating filtered aggregates the condition must not be nullable.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)