You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/07/07 09:38:08 UTC

[GitHub] [flink] TJX2014 opened a new pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

TJX2014 opened a new pull request #12819:
URL: https://github.com/apache/flink/pull/12819


   <!--
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   This PR makes Flink sql allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions 
   
   ## Brief change log
   Use `SqlRankFunction` in `flink-table-planner-blink` module which `allowsFraming()` return `true` to overwrite this one in `calcite` module which not allow framing.
   
   ## Verifying this change
   
   Unit test can be used to test.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / **no**)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / **not documented**)
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 commented on a change in pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 commented on a change in pull request #12819:
URL: https://github.com/apache/flink/pull/12819#discussion_r450005475



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/SqlRankFunction.java
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;
+
+import org.apache.calcite.sql.type.OperandTypes;
+import org.apache.calcite.sql.type.ReturnTypes;
+import org.apache.calcite.sql.type.SqlReturnTypeInference;
+import org.apache.calcite.util.Optionality;
+
+/**
+ * Operator which aggregates sets of values into a result.
+ */
+public class SqlRankFunction extends SqlAggFunction {
+	//~ Constructors -----------------------------------------------------------
+
+	@Deprecated
+	public SqlRankFunction(boolean requiresOrder, SqlKind kind) {
+		this(kind, ReturnTypes.INTEGER, requiresOrder);
+	}
+
+	public SqlRankFunction(SqlKind kind, SqlReturnTypeInference returnTypes,
+						   boolean requiresOrder) {
+		super(kind.name(), null, kind, returnTypes, null,
+			OperandTypes.NILADIC, SqlFunctionCategory.NUMERIC, requiresOrder,
+			true, Optionality.FORBIDDEN);
+	}
+
+	//~ Methods ----------------------------------------------------------------
+
+	// FLINK-18440:
+	// Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream
+	@Override public boolean allowsFraming() {
+		return true;

Review comment:
       We only need result of `allowsFraming` to be true.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW_NUMBER function: ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d26462bf2cc8169675451ec32ee5f706ec2143c3 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] wuchong closed pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
wuchong closed pull request #12819:
URL: https://github.com/apache/flink/pull/12819


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] wuchong commented on a change in pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #12819:
URL: https://github.com/apache/flink/pull/12819#discussion_r449993292



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/SqlRankFunction.java
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;
+
+import org.apache.calcite.sql.type.OperandTypes;
+import org.apache.calcite.sql.type.ReturnTypes;
+import org.apache.calcite.sql.type.SqlReturnTypeInference;
+import org.apache.calcite.util.Optionality;
+
+/**
+ * Operator which aggregates sets of values into a result.
+ */
+public class SqlRankFunction extends SqlAggFunction {
+	//~ Constructors -----------------------------------------------------------
+
+	@Deprecated
+	public SqlRankFunction(boolean requiresOrder, SqlKind kind) {
+		this(kind, ReturnTypes.INTEGER, requiresOrder);
+	}
+
+	public SqlRankFunction(SqlKind kind, SqlReturnTypeInference returnTypes,
+						   boolean requiresOrder) {
+		super(kind.name(), null, kind, returnTypes, null,
+			OperandTypes.NILADIC, SqlFunctionCategory.NUMERIC, requiresOrder,
+			true, Optionality.FORBIDDEN);
+	}
+
+	//~ Methods ----------------------------------------------------------------
+
+	// FLINK-18440:
+	// Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream
+	@Override public boolean allowsFraming() {
+		return true;

Review comment:
       What's the relationship between micro batch and this?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 commented on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 commented on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-654730833


   > > Could you rebase your branch on the latest mater? There is some merge commits in it and there are some conflicts when I want to rebase it.
   @wuchong 
   Ok , I will try to rebase my branch and try find udf way that have a `FlinkSqlRankFunction` in flink.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 commented on a change in pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 commented on a change in pull request #12819:
URL: https://github.com/apache/flink/pull/12819#discussion_r450003842



##########
File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/TableScanTest.scala
##########
@@ -357,4 +357,20 @@ class TableScanTest extends TableTestBase {
         |)
       """.stripMargin)
   }
+
+  @Test
+  def testRowNumOverWindow(): Unit = {
+    util.addTable(
+      """
+        |CREATE TABLE src (
+        |  name STRING,
+        |  age BIGINT
+        |) WITH (
+        |  'connector' = 'values'
+        |)
+      """.stripMargin)
+    util.tableEnv.executeSql("create view src_view as select *, " +
+      "ROW_NUMBER() OVER (PARTITION BY name ORDER BY age DESC) as row_num from src")
+    util.verifyPlan("select name, age, row_num from src_view where row_num <= 3")

Review comment:
       Done




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] wuchong commented on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
wuchong commented on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-657337195


   Hi @TJX2014 , thanks a lot for the contribution and the great work. Danny has investigated this problem and gave a fix in #12868 . Will close this PR then. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW_NUMBER function: ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d26462bf2cc8169675451ec32ee5f706ec2143c3 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209) 
   * 9d62744ad9b4c2796aa02b96096b5340dd6163b8 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW_NUMBER function: ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d26462bf2cc8169675451ec32ee5f706ec2143c3 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] wuchong commented on a change in pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #12819:
URL: https://github.com/apache/flink/pull/12819#discussion_r450668244



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/SqlRankFunction.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;

Review comment:
       I agree we only need to return true for `allowsFraming`. However, I think we should avoid to overwrite a Calcite class. The suggested way for UDF is that we can have a `FlinkSqlRankFunction` which is located in flink package.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 commented on a change in pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 commented on a change in pull request #12819:
URL: https://github.com/apache/flink/pull/12819#discussion_r450004284



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/SqlRankFunction.java
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;
+
+import org.apache.calcite.sql.type.OperandTypes;
+import org.apache.calcite.sql.type.ReturnTypes;
+import org.apache.calcite.sql.type.SqlReturnTypeInference;
+import org.apache.calcite.util.Optionality;
+
+/**
+ * Operator which aggregates sets of values into a result.
+ */
+public class SqlRankFunction extends SqlAggFunction {
+	//~ Constructors -----------------------------------------------------------
+
+	@Deprecated
+	public SqlRankFunction(boolean requiresOrder, SqlKind kind) {
+		this(kind, ReturnTypes.INTEGER, requiresOrder);
+	}
+
+	public SqlRankFunction(SqlKind kind, SqlReturnTypeInference returnTypes,
+						   boolean requiresOrder) {
+		super(kind.name(), null, kind, returnTypes, null,
+			OperandTypes.NILADIC, SqlFunctionCategory.NUMERIC, requiresOrder,
+			true, Optionality.FORBIDDEN);
+	}
+
+	//~ Methods ----------------------------------------------------------------
+
+	// FLINK-18440:
+	// Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream
+	@Override public boolean allowsFraming() {
+		return true;

Review comment:
       The test for stream rank need this, maybe we  could ignore micro batch.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 commented on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 commented on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-655345736






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4249",
       "triggerID" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "triggerType" : "PUSH"
     }, {
       "hash" : "39695e399f55065af72ea98906892448c3d5b315",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4253",
       "triggerID" : "39695e399f55065af72ea98906892448c3d5b315",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4249) 
   * 39695e399f55065af72ea98906892448c3d5b315 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4253) 
   * 3abfccb9772dc89d051cdc9924af785e25488563 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW_NUMBER function: ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653471084


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit d26462bf2cc8169675451ec32ee5f706ec2143c3 (Fri Jul 03 10:17:33 UTC 2020)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
    * **This pull request references an unassigned [Jira ticket](https://issues.apache.org/jira/browse/FLINK-18440).** According to the [code contribution guide](https://flink.apache.org/contributing/contribute-code.html), tickets need to be assigned before starting with the implementation work.
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4249",
       "triggerID" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9d62744ad9b4c2796aa02b96096b5340dd6163b8 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217) 
   * c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4249) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] danny0405 commented on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
danny0405 commented on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-656048735


   > After reading the discussion of https://issues.apache.org/jira/browse/CALCITE-4107, I think we should re-think the solution. I agree RANK & DENSE_RANK shouldn't allow ROWS or RANGE, and our queries do not contain ROWS and RANGE. So, `allowsFraming` is not the correct fixing way.
   > 
   > cc @danny0405 Could you help to investigate this?
   
   Sure, let me take a look.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-655345736


   hi @wuchong , thank you for your suggestion, I have rebase my branch on the latest master. if our `FlinkSqlRankFunction` is named as `ROW_NUMBER_WINDOW()`, it seems hard to test in `org.apache.flink.table.planner.plan.stream.sql.RankTest`


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9d62744ad9b4c2796aa02b96096b5340dd6163b8 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217) 
   * c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 removed a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 removed a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-654729708


   > Could you rebase your branch on the latest mater? There is some merge commits in it and there are some conflicts when I want to rebase it.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 commented on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 commented on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-657464358


   Thank you all for your help, hope next time I can commit : )


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4249",
       "triggerID" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "triggerType" : "PUSH"
     }, {
       "hash" : "39695e399f55065af72ea98906892448c3d5b315",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4253",
       "triggerID" : "39695e399f55065af72ea98906892448c3d5b315",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 39695e399f55065af72ea98906892448c3d5b315 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4253) 
   * 3abfccb9772dc89d051cdc9924af785e25488563 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 commented on a change in pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 commented on a change in pull request #12819:
URL: https://github.com/apache/flink/pull/12819#discussion_r449990838



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/SqlRankFunction.java
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;
+
+import org.apache.calcite.sql.type.OperandTypes;
+import org.apache.calcite.sql.type.ReturnTypes;
+import org.apache.calcite.sql.type.SqlReturnTypeInference;
+import org.apache.calcite.util.Optionality;
+
+/**
+ * Operator which aggregates sets of values into a result.
+ */
+public class SqlRankFunction extends SqlAggFunction {
+	//~ Constructors -----------------------------------------------------------
+
+	@Deprecated
+	public SqlRankFunction(boolean requiresOrder, SqlKind kind) {
+		this(kind, ReturnTypes.INTEGER, requiresOrder);
+	}
+
+	public SqlRankFunction(SqlKind kind, SqlReturnTypeInference returnTypes,
+						   boolean requiresOrder) {
+		super(kind.name(), null, kind, returnTypes, null,
+			OperandTypes.NILADIC, SqlFunctionCategory.NUMERIC, requiresOrder,
+			true, Optionality.FORBIDDEN);
+	}
+
+	//~ Methods ----------------------------------------------------------------
+
+	// FLINK-18440:
+	// Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream
+	@Override public boolean allowsFraming() {
+		return true;

Review comment:
       Return true is mainly due to in micro batch, row_number need to be allowed, hope ` FLINK-18440:  Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream` could be useful.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 commented on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 commented on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-654729708


   > Could you rebase your branch on the latest mater? There is some merge commits in it and there are some conflicts when I want to rebase it.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW_NUMBER function: ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9d62744ad9b4c2796aa02b96096b5340dd6163b8 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 closed pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 closed pull request #12819:
URL: https://github.com/apache/flink/pull/12819


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 commented on a change in pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 commented on a change in pull request #12819:
URL: https://github.com/apache/flink/pull/12819#discussion_r449990273



##########
File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/TableScanTest.scala
##########
@@ -357,4 +357,20 @@ class TableScanTest extends TableTestBase {
         |)
       """.stripMargin)
   }
+
+  @Test
+  def testRowNumOverWindow(): Unit = {
+    util.addTable(
+      """
+        |CREATE TABLE src (
+        |  name STRING,
+        |  age BIGINT
+        |) WITH (
+        |  'connector' = 'values'
+        |)
+      """.stripMargin)
+    util.tableEnv.executeSql("create view src_view as select *, " +
+      "ROW_NUMBER() OVER (PARTITION BY name ORDER BY age DESC) as row_num from src")
+    util.verifyPlan("select name, age, row_num from src_view where row_num <= 3")

Review comment:
       @wuchong Thank you for your suggestion, I have made the test code clean and meaningful.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW_NUMBER function: ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d26462bf2cc8169675451ec32ee5f706ec2143c3 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209) 
   * 9d62744ad9b4c2796aa02b96096b5340dd6163b8 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 commented on a change in pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 commented on a change in pull request #12819:
URL: https://github.com/apache/flink/pull/12819#discussion_r450002947



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/SqlRankFunction.java
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;
+
+import org.apache.calcite.sql.type.OperandTypes;
+import org.apache.calcite.sql.type.ReturnTypes;
+import org.apache.calcite.sql.type.SqlReturnTypeInference;
+import org.apache.calcite.util.Optionality;
+
+/**
+ * Operator which aggregates sets of values into a result.
+ */
+public class SqlRankFunction extends SqlAggFunction {
+	//~ Constructors -----------------------------------------------------------
+
+	@Deprecated
+	public SqlRankFunction(boolean requiresOrder, SqlKind kind) {
+		this(kind, ReturnTypes.INTEGER, requiresOrder);
+	}
+
+	public SqlRankFunction(SqlKind kind, SqlReturnTypeInference returnTypes,
+						   boolean requiresOrder) {
+		super(kind.name(), null, kind, returnTypes, null,
+			OperandTypes.NILADIC, SqlFunctionCategory.NUMERIC, requiresOrder,
+			true, Optionality.FORBIDDEN);
+	}
+
+	//~ Methods ----------------------------------------------------------------
+
+	// FLINK-18440:
+	// Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Review comment:
       Thank you for your detail information, I have created a issue in calcite community. [https://issues.apache.org/jira/browse/CALCITE-4107](https://issues.apache.org/jira/browse/CALCITE-4107)




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4249",
       "triggerID" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "triggerType" : "PUSH"
     }, {
       "hash" : "39695e399f55065af72ea98906892448c3d5b315",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "39695e399f55065af72ea98906892448c3d5b315",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4249) 
   * 39695e399f55065af72ea98906892448c3d5b315 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 removed a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 removed a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-655345802


   th


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 closed pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 closed pull request #12819:
URL: https://github.com/apache/flink/pull/12819


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4249",
       "triggerID" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "triggerType" : "PUSH"
     }, {
       "hash" : "39695e399f55065af72ea98906892448c3d5b315",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4253",
       "triggerID" : "39695e399f55065af72ea98906892448c3d5b315",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4257",
       "triggerID" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "triggerType" : "PUSH"
     }, {
       "hash" : "115eddb01036d1310c0b3322a115a68503fe6368",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4319",
       "triggerID" : "115eddb01036d1310c0b3322a115a68503fe6368",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 3abfccb9772dc89d051cdc9924af785e25488563 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4257) 
   * 115eddb01036d1310c0b3322a115a68503fe6368 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4319) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] wuchong commented on a change in pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #12819:
URL: https://github.com/apache/flink/pull/12819#discussion_r449993715



##########
File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/TableScanTest.scala
##########
@@ -357,4 +357,20 @@ class TableScanTest extends TableTestBase {
         |)
       """.stripMargin)
   }
+
+  @Test
+  def testRowNumOverWindow(): Unit = {
+    util.addTable(
+      """
+        |CREATE TABLE src (
+        |  name STRING,
+        |  age BIGINT
+        |) WITH (
+        |  'connector' = 'values'
+        |)
+      """.stripMargin)
+    util.tableEnv.executeSql("create view src_view as select *, " +
+      "ROW_NUMBER() OVER (PARTITION BY name ORDER BY age DESC) as row_num from src")
+    util.verifyPlan("select name, age, row_num from src_view where row_num <= 3")

Review comment:
       Please move this case to `RankTest` with test method name `testOverWindowInView`.

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/SqlRankFunction.java
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;
+
+import org.apache.calcite.sql.type.OperandTypes;
+import org.apache.calcite.sql.type.ReturnTypes;
+import org.apache.calcite.sql.type.SqlReturnTypeInference;
+import org.apache.calcite.util.Optionality;
+
+/**
+ * Operator which aggregates sets of values into a result.
+ */
+public class SqlRankFunction extends SqlAggFunction {
+	//~ Constructors -----------------------------------------------------------
+
+	@Deprecated
+	public SqlRankFunction(boolean requiresOrder, SqlKind kind) {
+		this(kind, ReturnTypes.INTEGER, requiresOrder);
+	}
+
+	public SqlRankFunction(SqlKind kind, SqlReturnTypeInference returnTypes,
+						   boolean requiresOrder) {
+		super(kind.name(), null, kind, returnTypes, null,
+			OperandTypes.NILADIC, SqlFunctionCategory.NUMERIC, requiresOrder,
+			true, Optionality.FORBIDDEN);
+	}
+
+	//~ Methods ----------------------------------------------------------------
+
+	// FLINK-18440:
+	// Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Review comment:
       I mean create an issue in Calcite community and link the calcite issue here. 

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/SqlRankFunction.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;

Review comment:
       This is not updated?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4249",
       "triggerID" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "triggerType" : "PUSH"
     }, {
       "hash" : "39695e399f55065af72ea98906892448c3d5b315",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4253",
       "triggerID" : "39695e399f55065af72ea98906892448c3d5b315",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4257",
       "triggerID" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "triggerType" : "PUSH"
     }, {
       "hash" : "115eddb01036d1310c0b3322a115a68503fe6368",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "115eddb01036d1310c0b3322a115a68503fe6368",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 3abfccb9772dc89d051cdc9924af785e25488563 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4257) 
   * 115eddb01036d1310c0b3322a115a68503fe6368 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW_NUMBER function: ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d26462bf2cc8169675451ec32ee5f706ec2143c3 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4249",
       "triggerID" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "triggerType" : "PUSH"
     }, {
       "hash" : "39695e399f55065af72ea98906892448c3d5b315",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4253",
       "triggerID" : "39695e399f55065af72ea98906892448c3d5b315",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4257",
       "triggerID" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "triggerType" : "PUSH"
     }, {
       "hash" : "115eddb01036d1310c0b3322a115a68503fe6368",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4319",
       "triggerID" : "115eddb01036d1310c0b3322a115a68503fe6368",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 115eddb01036d1310c0b3322a115a68503fe6368 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4319) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] wuchong commented on a change in pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW_NUMBER function: ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #12819:
URL: https://github.com/apache/flink/pull/12819#discussion_r449959578



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/SqlRankFunction.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;

Review comment:
       It's not suggested to rewrite a Calcite class, unless it's the only way to do it. Otherwise, the code will be hard to mantain. 
   
   In this case, we can have a `FlinkSqlRankFunction` which is located in flink package. 
   Besides, we should create an issue in Calcite, and link the issue in the `FlinkSqlRankFunction` to tell the maintainer to remove this class once the issue is fixed. 

##########
File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/TableScanTest.scala
##########
@@ -357,4 +357,33 @@ class TableScanTest extends TableTestBase {
         |)
       """.stripMargin)
   }
+
+  @Test
+  def testRowNumOverWindow(): Unit = {
+    util.addTable(
+      """
+        |CREATE TABLE test_source (
+        |  name STRING,
+        |  eat STRING,
+        |  age BIGINT
+        |) WITH (
+        |  'connector' = 'values'
+        |)
+      """.stripMargin)
+
+    util.tableEnv.executeSql("create view test as select name, eat ,sum(age) as cnt from test_source group by name,eat")
+    util.tableEnv.executeSql("create view resultsssss as select *, ROW_NUMBER() OVER (PARTITION BY name ORDER BY cnt DESC) as row_num from test")
+    util.addTable(
+      s"""
+         |create table sink (
+         |name varchar,
+         |eat varchar,
+         |cnt bigint
+         |)
+         |with(
+         |'connector' = 'print'
+         |)
+      """.stripMargin)
+    util.verifyPlanInsert("insert into sink select name,eat,cnt from resultsssss where row_num <= 3")

Review comment:
       Don't need INSERT INTO. You can just call `util.verifyPlan("SELECT ...")`

##########
File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/TableScanTest.scala
##########
@@ -357,4 +357,33 @@ class TableScanTest extends TableTestBase {
         |)
       """.stripMargin)
   }
+
+  @Test
+  def testRowNumOverWindow(): Unit = {
+    util.addTable(
+      """
+        |CREATE TABLE test_source (
+        |  name STRING,
+        |  eat STRING,
+        |  age BIGINT
+        |) WITH (
+        |  'connector' = 'values'
+        |)
+      """.stripMargin)
+
+    util.tableEnv.executeSql("create view test as select name, eat ,sum(age) as cnt from test_source group by name,eat")
+    util.tableEnv.executeSql("create view resultsssss as select *, ROW_NUMBER() OVER (PARTITION BY name ORDER BY cnt DESC) as row_num from test")

Review comment:
       Please give a meaningful view name. 

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/SqlRankFunction.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;
+
+import org.apache.calcite.sql.type.OperandTypes;
+import org.apache.calcite.sql.type.ReturnTypes;
+import org.apache.calcite.sql.type.SqlReturnTypeInference;
+import org.apache.calcite.util.Optionality;
+
+/**
+ * Operator which aggregates sets of values into a result.
+ */
+public class SqlRankFunction extends SqlAggFunction {
+	//~ Constructors -----------------------------------------------------------
+
+	@Deprecated
+	public SqlRankFunction(boolean requiresOrder, SqlKind kind) {
+		this(kind, ReturnTypes.INTEGER, requiresOrder);
+	}
+
+	public SqlRankFunction(SqlKind kind, SqlReturnTypeInference returnTypes,
+						   boolean requiresOrder) {
+		super(kind.name(), null, kind, returnTypes, null,
+			OperandTypes.NILADIC, SqlFunctionCategory.NUMERIC, requiresOrder,
+			true, Optionality.FORBIDDEN);
+	}
+
+	//~ Methods ----------------------------------------------------------------
+
+	@Override public boolean allowsFraming() {
+		return true;

Review comment:
       Please add comment why we have to override this method and allow framing. 




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4249",
       "triggerID" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "triggerType" : "PUSH"
     }, {
       "hash" : "39695e399f55065af72ea98906892448c3d5b315",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4253",
       "triggerID" : "39695e399f55065af72ea98906892448c3d5b315",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4257",
       "triggerID" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 3abfccb9772dc89d051cdc9924af785e25488563 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4257) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] wuchong commented on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
wuchong commented on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-655973464


   After reading the discussion of https://issues.apache.org/jira/browse/CALCITE-4107, I think we should re-think the solution. I agree RANK & DENSE_RANK shouldn't allow ROWS or RANGE, and our queries do not contain ROWS and RANGE. So, `allowsFraming` is not the correct fixing way. 
   
   cc @danny0405 Could you help to investigate this?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12819:
URL: https://github.com/apache/flink/pull/12819#issuecomment-653477506


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4209",
       "triggerID" : "d26462bf2cc8169675451ec32ee5f706ec2143c3",
       "triggerType" : "PUSH"
     }, {
       "hash" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4217",
       "triggerID" : "9d62744ad9b4c2796aa02b96096b5340dd6163b8",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4249",
       "triggerID" : "c4da26a262bc3b5e61ad7ca058c319a7e5fb17bd",
       "triggerType" : "PUSH"
     }, {
       "hash" : "39695e399f55065af72ea98906892448c3d5b315",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4253",
       "triggerID" : "39695e399f55065af72ea98906892448c3d5b315",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4257",
       "triggerID" : "3abfccb9772dc89d051cdc9924af785e25488563",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 39695e399f55065af72ea98906892448c3d5b315 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4253) 
   * 3abfccb9772dc89d051cdc9924af785e25488563 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4257) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [flink] TJX2014 commented on a change in pull request #12819: [FLINK-18440][table-planner-blink] Allow ROW/RANGE with RANK, DENSE_RANK or ROW_NUMBER functions on window stream

Posted by GitBox <gi...@apache.org>.
TJX2014 commented on a change in pull request #12819:
URL: https://github.com/apache/flink/pull/12819#discussion_r450006339



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/sql/SqlRankFunction.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql;

Review comment:
       Seems just need the result of `org.apache.calcite.sql.SqlRankFunction#allowsFraming` to be true.[https://github.com/apache/flink/pull/12819#discussion_r450005475](https://github.com/apache/flink/pull/12819#discussion_r450005475)




----------------------------------------------------------------
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:
users@infra.apache.org