KurtYoung commented on a change in pull request #8051: [FLINK-12018] [table-planner-blink] Add support for generating optimized logical plan for Sort and Rank URL: https://github.com/apache/flink/pull/8051#discussion_r270618704
########## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/nodes/calcite/Rank.scala ########## @@ -91,10 +89,13 @@ abstract class Rank( } override def deriveRowType(): RelDataType = { + if (!outputRankNumber) { + return input.getRowType + } val typeFactory = cluster.getRexBuilder.getTypeFactory val typeBuilder = typeFactory.builder() input.getRowType.getFieldList.foreach(typeBuilder.add) - // rank function column is always the last column, and its type is BIGINT NOT NULL + // rank number column is always the last column, and its type is BIGINT NOT NULL val allFieldNames = new util.HashSet[String]() allFieldNames.addAll(input.getRowType.getFieldNames) val rankFieldName = FlinkRelOptUtil.buildUniqueFieldName(allFieldNames, "rk") Review comment: Why we can force the rank field name to "rk"? What if the user specified the name for it? Like: SELECT * FROM ( SELECT a, b, RANK() OVER (PARTITION BY b ORDER BY c) `myRank` FROM MyTable ) t WHERE `myRank` < 10 ? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services