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 2018/11/13 03:31:28 UTC

[GitHub] hequn8128 commented on a change in pull request #7079: [FLINK-10845][table] Support multiple different DISTINCT aggregates for batch

hequn8128 commented on a change in pull request #7079: [FLINK-10845][table] Support multiple different DISTINCT aggregates for batch
URL: https://github.com/apache/flink/pull/7079#discussion_r232887066
 
 

 ##########
 File path: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/runtime/batch/sql/AggregateITCase.scala
 ##########
 @@ -559,4 +559,57 @@ class AggregateITCase(
 
     TestBaseUtils.compareResultAsText(result.asJava, expected)
   }
+
+  @Test
+  def testMultipleDistinctWithDiffParams(): Unit = {
+    val env = ExecutionEnvironment.getExecutionEnvironment
+    val tEnv = TableEnvironment.getTableEnvironment(env, config)
+    val sqlQuery =
+      "SELECT b, " +
+      "  SUM(DISTINCT (a / 3)), " +
+      "  COUNT(DISTINCT SUBSTRING(c FROM 1 FOR 2))," +
+      "  COUNT(DISTINCT c) " +
+      "FROM MyTable " +
+      "GROUP BY b " +
+      "ORDER BY b"
+
+    val data = new scala.collection.mutable.MutableList[(Int, Long, String)]
 
 Review comment:
   Replace this with `CollectionDataSets.get5TupleDataSet(env)`.
   I think we can add a `case when` to generate null data. For example:
   ```
       val t = CollectionDataSets.get5TupleDataSet(env).toTable(tEnv).as('a, 'b, 'c, 'd, 'e)
       tEnv.registerTable("MyTable", t)
       val sqlAddNull = "SELECT a, b, c, e, CASE d WHEN 'Hallo' THEN null ELSE d END AS d From MyTable"
       val sqlQuery =
         "SELECT d, " +
         "  COUNT(DISTINCT d), " +
         "  COUNT(DISTINCT e) " +
         s"FROM ($sqlAddNull) " +
         "GROUP BY d " +
         "ORDER BY d"
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services