wuchong commented on a change in pull request #15003:
URL: https://github.com/apache/flink/pull/15003#discussion_r582661033



##########
File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/agg/WindowAggregateTest.scala
##########
@@ -683,4 +682,165 @@ class WindowAggregateTest extends TableTestBase {
       "must be an integral multiple of step, but got maxSize 3600000 ms and 
step 1500000 ms")
     util.verifyExplain(sql)
   }
+
+  @Test
+  def testCantMergeWindowTVF_GroupingSetsWithoutWindowStartEnd(): Unit = {
+    val sql =
+      """
+        |SELECT
+        |   a,
+        |   count(distinct c) AS uv
+        |FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '15' 
MINUTE))
+        |GROUP BY GROUPING SETS ((a), (window_start), (window_end))
+      """.stripMargin
+    util.verifyRelPlan(sql)
+  }
+
+  @Test
+  def testCantMergeWindowTVF_GroupingSetsOnlyWithWindowStart(): Unit = {

Review comment:
       ditto.

##########
File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/agg/WindowAggregateTest.scala
##########
@@ -683,4 +682,165 @@ class WindowAggregateTest extends TableTestBase {
       "must be an integral multiple of step, but got maxSize 3600000 ms and 
step 1500000 ms")
     util.verifyExplain(sql)
   }
+
+  @Test

Review comment:
       Could you add some tests for other grouping sets syntax, including 
`CUBE`, `ROLL`. 

##########
File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/agg/WindowAggregateTest.scala
##########
@@ -683,4 +682,165 @@ class WindowAggregateTest extends TableTestBase {
       "must be an integral multiple of step, but got maxSize 3600000 ms and 
step 1500000 ms")
     util.verifyExplain(sql)
   }
+
+  @Test
+  def testCantMergeWindowTVF_GroupingSetsWithoutWindowStartEnd(): Unit = {
+    val sql =
+      """
+        |SELECT
+        |   a,
+        |   count(distinct c) AS uv
+        |FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '15' 
MINUTE))
+        |GROUP BY GROUPING SETS ((a), (window_start), (window_end))
+      """.stripMargin
+    util.verifyRelPlan(sql)
+  }
+
+  @Test
+  def testCantMergeWindowTVF_GroupingSetsOnlyWithWindowStart(): Unit = {
+    val sql =
+      """
+        |SELECT
+        |   a,
+        |   count(distinct c) AS uv
+        |FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '15' 
MINUTE))
+        |GROUP BY GROUPING SETS ((a, window_start), (window_start))
+      """.stripMargin
+    util.verifyRelPlan(sql)
+  }
+
+  @Test
+  def testTumble_GroupingSets(): Unit = {
+    val sql =
+      """
+        |SELECT
+        |   a,
+        |   b,
+        |   count(distinct c) AS uv
+        |FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '15' 
MINUTE))
+        |GROUP BY GROUPING SETS ((a, window_start, window_end), (b, 
window_start, window_end))
+      """.stripMargin
+    util.verifyRelPlan(sql)
+  }
+
+  @Test
+  def testTumble_GroupingSets1(): Unit = {
+    val sql =
+      """
+        |SELECT
+        |   a,
+        |   b,
+        |   count(distinct c) AS uv
+        |FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '15' 
MINUTE))
+        |GROUP BY GROUPING SETS ((a), (b)), window_start, window_end
+      """.stripMargin
+    util.verifyRelPlan(sql)
+  }
+
+  @Test
+  def testTumble_GroupingSetsDistinctSplitEnabled(): Unit = {
+    util.tableEnv.getConfig.getConfiguration.setBoolean(
+      OptimizerConfigOptions.TABLE_OPTIMIZER_DISTINCT_AGG_SPLIT_ENABLED, true)
+    val sql =
+      """
+        |SELECT
+        |   a,
+        |   b,
+        |   count(*),
+        |   sum(d),
+        |   max(d) filter (where b > 1000),
+        |   count(distinct c) AS uv
+        |FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '15' 
MINUTE))
+        |GROUP BY GROUPING SETS ((a), (b)), window_start, window_end
+      """.stripMargin
+    util.verifyRelPlan(sql)
+  }
+
+  @Test
+  def testTumble_GroupingSetsDistinctOnWindowColumns(): Unit = {

Review comment:
       Should rename to `testCantMergeWindowTVF_`

##########
File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/agg/WindowAggregateTest.scala
##########
@@ -683,4 +682,165 @@ class WindowAggregateTest extends TableTestBase {
       "must be an integral multiple of step, but got maxSize 3600000 ms and 
step 1500000 ms")
     util.verifyExplain(sql)
   }
+
+  @Test
+  def testCantMergeWindowTVF_GroupingSetsWithoutWindowStartEnd(): Unit = {

Review comment:
       Should be `testCantTranslateToWindowAgg_` because the group keys don't 
contain both window_start and window_end, so there is no `WindowAggregate`, but 
`GroupAggregate`. 




----------------------------------------------------------------
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


Reply via email to