godfrey he created FLINK-23434: ---------------------------------- Summary: Inconsistent rowtypes occur in IncrementalAggregateRule Key: FLINK-23434 URL: https://issues.apache.org/jira/browse/FLINK-23434 Project: Flink Issue Type: Bug Components: Table SQL / Planner Affects Versions: 1.13.0, 1.14.0 Reporter: godfrey he Assignee: godfrey he
add the following test in IncrementalAggregateTest, and will get the following exception {code:java} @Test def testSumCountWithSingleDistinctAndRetraction(): Unit = { val sqlQuery = s""" |SELECT | b, SUM(b1), COUNT(DISTINCT b1), COUNT(1) |FROM( | SELECT | a, COUNT(b) as b, MAX(b) as b1 | FROM MyTable | GROUP BY a |) GROUP BY b """.stripMargin util.verifyRelPlan(sqlQuery, ExplainDetail.CHANGELOG_MODE) } {code} {code:java} java.lang.IllegalStateException at org.apache.flink.util.Preconditions.checkState(Preconditions.java:177) at org.apache.flink.table.planner.plan.rules.physical.stream.IncrementalAggregateRule.onMatch(IncrementalAggregateRule.scala:127) at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:333) at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:542) at org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:407) at org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:271) at org.apache.calcite.plan.hep.HepInstruction$RuleCollection.execute(HepInstruction.java:74) at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:202) at org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:189) at org.apache.flink.table.planner.plan.optimize.program.FlinkHepProgram.optimize(FlinkHepProgram.scala:69) {code} The reason is the global agg on incremental agg does not handle retraction message in IncrementalAggregateRule when the query has one distinct agg function and count star agg function . -- This message was sent by Atlassian Jira (v8.3.4#803005)