[ 
https://issues.apache.org/jira/browse/BEAM-5103?focusedWorklogId=132284&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-132284
 ]

ASF GitHub Bot logged work on BEAM-5103:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/Aug/18 09:40
            Start Date: 08/Aug/18 09:40
    Worklog Time Spent: 10m 
      Work Description: vectorijk commented on a change in pull request #6175: 
[BEAM-5103][SQL]test aggregation functions at DSL level
URL: https://github.com/apache/beam/pull/6175#discussion_r208518731
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslSqlStdOperatorsTest.java
 ##########
 @@ -515,6 +515,71 @@ public void testComparisonOperatorFunction() {
     checker.buildRunAndCheck();
   }
 
+  @Test
+  @SqlOperatorTest(name = "MAX", kind = "MAX")
+  @SqlOperatorTest(name = "MIN", kind = "MIN")
+  @SqlOperatorTest(name = "SUM", kind = "SUM")
+  @SqlOperatorTest(name = "AVG", kind = "AVG")
+  @SqlOperatorTest(name = "$SUM0", kind = "SUM0")
+  @SqlOperatorTest(name = "COUNT", kind = "COUNT")
+  @SqlOperatorTest(name = "VAR_POP", kind = "VAR_POP")
+  @SqlOperatorTest(name = "VAR_SAMP", kind = "VAR_SAMP")
+  @SqlOperatorTest(name = "COVAR_POP", kind = "COVAR_POP")
+  @SqlOperatorTest(name = "COVAR_SAMP", kind = "COVAR_SAMP")
+  public void testAggrationFunctions() {
+    ExpressionChecker checker =
+        new ExpressionChecker()
+            .addExpr("MAX(c_tinyint)", (byte) 3)
+            .addExpr("MAX(c_smallint)", (short) 3)
+            .addExpr("MAX(c_integer)", 3)
+            .addExpr("MAX(c_bigint)", 3L)
+            .addExpr("MAX(c_float)", 3.0f)
+            .addExpr("MAX(c_double)", 3.0)
+            .addExpr("MAX(c_decimal)", BigDecimal.valueOf(3.0))
+            .addExpr("MAX(ts)", parseDate("1986-04-15 11:35:26"))
+            .addExpr("MIN(c_tinyint)", (byte) 1)
+            .addExpr("MIN(c_smallint)", (short) 1)
+            .addExpr("MIN(c_integer)", 1)
+            .addExpr("MIN(c_bigint)", 1L)
+            .addExpr("MIN(c_float)", 1.0f)
+            .addExpr("MIN(c_double)", 1.0)
+            .addExpr("MIN(c_decimal)", BigDecimal.valueOf(1.0))
+            .addExpr("MIN(ts)", parseDate("1986-02-15 11:35:26"))
+            .addExpr("SUM(c_tinyint)", (byte) 6)
+            .addExpr("SUM(c_smallint)", (short) 6)
+            .addExpr("SUM(c_integer)", 6)
+            .addExpr("SUM(c_bigint)", 6L)
+            .addExpr("SUM(c_float)", 6.0f)
+            .addExpr("SUM(c_double)", 6.0)
+            .addExpr("SUM(c_decimal)", BigDecimal.valueOf(6.0))
+            .addExpr("AVG(c_tinyint)", (byte) 2)
+            .addExpr("AVG(c_smallint)", (short) 2)
+            .addExpr("AVG(c_integer)", 2)
+            .addExpr("AVG(c_bigint)", 2L)
+            .addExpr("AVG(c_float)", 2.0f)
+            .addExpr("AVG(c_double)", 2.0)
+            .addExpr("AVG(c_decimal)", BigDecimal.valueOf(2.0))
+            .addExpr("COUNT(*)", 3L)
+            .addExpr("COUNT(1)", 3L)
+            .addExpr("$SUM0(c_tinyint)", (byte) 6)
 
 Review comment:
   According to definition of `Sum0` in 
[Calcite](https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/fun/SqlSumEmptyIsZeroAggFunction.java#L34-L37),
 if all values are null, `Sum0` should return 0 and `Sum` returns null. I think 
what Kenn does currently for `Sum0` is just simply use same `SUM` aggregation 
func. Could you also add another test for this case at DSL level?

----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 132284)
    Time Spent: 0.5h  (was: 20m)

> Test aggregation functions at DSL levels
> ----------------------------------------
>
>                 Key: BEAM-5103
>                 URL: https://issues.apache.org/jira/browse/BEAM-5103
>             Project: Beam
>          Issue Type: Sub-task
>          Components: dsl-sql
>            Reporter: Rui Wang
>            Assignee: Rui Wang
>            Priority: Major
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Typical aggregation functions include COUNT, SUM, MAX, MIN, etc.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to