[ https://issues.apache.org/jira/browse/FLINK-12249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16887011#comment-16887011 ]
Dawid Wysakowicz commented on FLINK-12249: ------------------------------------------ [~sunjincheng121] I agree that Calcite behaves correctly in cases where group set is empty. The problem though is we produce that false information intentionally (in a way). The reason is that there is no bit-like field in the input of `LogicalWindowAggregate` that we can group on. Calcite creates a {{LogicalAggregate}} that groups on value of function like {{TUMBLE(f0, ...)}}, we strip that information in {{LogicalWindowAggregateRule}} and perform the window assignment within the physical node. Therefore it is not as simple as just leave the idx there. [~hequn8128] What do you mean by: "We can simply use a Rule to achieve this"? I think the problem lies in the return type inference strategies, which cannot be adjusted in a Rule, or am I wrong? > Type equivalence check fails for Window Aggregates > -------------------------------------------------- > > Key: FLINK-12249 > URL: https://issues.apache.org/jira/browse/FLINK-12249 > Project: Flink > Issue Type: Bug > Components: Table SQL / Legacy Planner, Tests > Affects Versions: 1.9.0 > Reporter: Dawid Wysakowicz > Assignee: Hequn Cheng > Priority: Blocker > Fix For: 1.9.0 > > > Creating Aggregate node fails in rules: {{LogicalWindowAggregateRule}} and > {{ExtendedAggregateExtractProjectRule}} if the only grouping expression is a > window and > we compute aggregation on NON NULLABLE field. > The root cause for that, is how return type inference strategies in calcite > work and how we handle window aggregates. Take > {{org.apache.calcite.sql.type.ReturnTypes#AGG_SUM}} as an example, based on > {{groupCount}} it adjusts type nullability based on groupCount. > Though we pass a false information as we strip down window aggregation from > groupSet (in {{LogicalWindowAggregateRule}}). > One can reproduce this problem also with a unit test like this: > {code} > @Test > def testTumbleFunction2() = { > > val innerQuery = > """ > |SELECT > | CASE a WHEN 1 THEN 1 ELSE 99 END AS correct, > | rowtime > |FROM MyTable > """.stripMargin > val sql = > "SELECT " + > " SUM(correct) as cnt, " + > " TUMBLE_START(rowtime, INTERVAL '15' MINUTE) as wStart " + > s"FROM ($innerQuery) " + > "GROUP BY TUMBLE(rowtime, INTERVAL '15' MINUTE)" > val expected = "" > streamUtil.verifySql(sql, expected) > } > {code} > This causes e2e tests to fail: > https://travis-ci.org/apache/flink/builds/521183361?utm_source=slack&utm_medium=notificationhttps://travis-ci.org/apache/flink/builds/521183361?utm_source=slack&utm_medium=notification -- This message was sent by Atlassian JIRA (v7.6.14#76016)