coderfender commented on code in PR #2817:
URL: https://github.com/apache/datafusion-comet/pull/2817#discussion_r2644037316
##########
spark/src/test/scala/org/apache/comet/exec/CometAggregateSuite.scala:
##########
@@ -1472,6 +1472,104 @@ class CometAggregateSuite extends CometTestBase with
AdaptiveSparkPlanHelper {
}
}
+ test("AVG and try_avg - basic functionality") {
+ withParquetTable(
+ Seq(
+ (10L, 1),
+ (20L, 1),
+ (null.asInstanceOf[Long], 1),
+ (100L, 2),
+ (200L, 2),
+ (null.asInstanceOf[Long], 3)),
+ "tbl") {
+
+ Seq(true, false).foreach({ ansiMode =>
+ // without GROUP BY
+ withSQLConf(SQLConf.ANSI_ENABLED.key -> ansiMode.toString) {
+ val res = sql("SELECT avg(_1) FROM tbl")
+ checkSparkAnswerAndOperator(res)
+ assert(res.collect() === Array(Row(null)))
+ }
+
+ // with GROUP BY
+ withSQLConf(SQLConf.ANSI_ENABLED.key -> ansiMode.toString) {
+ val res = sql("SELECT _2, avg(_1) FROM tbl GROUP BY _2")
+ checkSparkAnswerAndOperator(res)
+ }
+ })
+
+ // try_avg without GROUP BY
+ val resTry = sql("SELECT try_avg(_1) FROM tbl")
+ checkSparkAnswerAndOperator(resTry)
+
+ // try_avg with GROUP BY
+ val resTryGroup = sql("SELECT _2, try_avg(_1) FROM tbl GROUP BY _2")
+ checkSparkAnswerAndOperator(resTryGroup)
+
+ }
+ }
+
+ test("AVG and try_avg - special numbers") {
+
+ val negativeNumbers = Seq(
+ (-1L, 1),
+ (-123L, 1),
+ (-456L, 1),
+ (-9223372036854775808L, 1),
+ (-9223372036854775808L, 1),
+ (-9223372036854775808L, 2),
+ (-9223372036854775807L, 2),
+ (null.asInstanceOf[String], 3)
Review Comment:
@andygrove . Thank you . I fixed the data types in the latest 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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]