[ https://issues.apache.org/jira/browse/FLINK-27519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17533221#comment-17533221 ]
jinfeng commented on FLINK-27519: --------------------------------- [~paul8263] Yes, there are already duplicate column names before the LOGICAL_CONVERTERS rule is applied, I think the easiest way is to modify FlinkLogicalOverAggregate if it cannot be fixed in calcite currently. > Fix duplicates names when there are multiple levels of over window aggregate > ---------------------------------------------------------------------------- > > Key: FLINK-27519 > URL: https://issues.apache.org/jira/browse/FLINK-27519 > Project: Flink > Issue Type: Bug > Components: Table SQL / Planner > Affects Versions: 1.15.0 > Reporter: jinfeng > Priority: Major > > A similar issue like > [FLINK-22121|https://issues.apache.org/jira/browse/FLINK-22121] > And can be reproduced by adding this unit test > org.apache.flink.table.planner.plan.stream.sql.agg.GroupWindowTest#testWindowAggregateWithAnotherWindowAggregate > {code:java} > //代码占位符 > @Test > def testWindowAggregateWithAnotherWindowAggregate(): Unit = { > val sql = > """ > |SELECT CAST(pv AS INT) AS pv, CAST(uv AS INT) AS uv FROM ( > | SELECT *, count(distinct(c)) over (partition by a order by b desc) > AS uv > | FROM ( > | SELECT *, count(*) over (partition by a, c order by b desc) AS pv > | FROM MyTable > | ) > |) > |""".stripMargin > util.verifyExecPlan(sql) > } {code} > The error message : > > > {code:java} > //代码占位符 > org.apache.flink.table.api.ValidationException: Field names must be unique. > Found duplicates: [w0$o0] at > org.apache.flink.table.types.logical.RowType.validateFields(RowType.java:273) > at org.apache.flink.table.types.logical.RowType.<init>(RowType.java:158) > at org.apache.flink.table.types.logical.RowType.of(RowType.java:298) > at org.apache.flink.table.types.logical.RowType.of(RowType.java:290) > at > org.apache.flink.table.planner.calcite.FlinkTypeFactory$.toLogicalRowType(FlinkTypeFactory.scala:663) > at > org.apache.flink.table.planner.plan.nodes.physical.stream.StreamPhysicalOverAggregate.translateToExecNode(StreamPhysicalOverAggregate.scala:57) > at > org.apache.flink.table.planner.plan.nodes.exec.ExecNodeGraphGenerator.generate(ExecNodeGraphGenerator.java:74) > at > org.apache.flink.table.planner.plan.nodes.exec.ExecNodeGraphGenerator.generate(ExecNodeGraphGenerator.java:71) > {code} > > I think we can add come logical in FlinkLogicalOverAggregate to avoid > duplicate names of output rowType. > > > -- This message was sent by Atlassian Jira (v8.20.7#820007)