huaxingao commented on code in PR #802:
URL: https://github.com/apache/datafusion-comet/pull/802#discussion_r1720430930
##########
spark/src/test/scala/org/apache/comet/exec/CometExecSuite.scala:
##########
@@ -1564,14 +1564,72 @@ class CometExecSuite extends CometTestBase {
}
}
+ test("aggregate window function for all types") {
+ val numValues = 2048
+
+ Seq(1, 100, numValues).foreach { numGroups =>
+ Seq(true, false).foreach { dictionaryEnabled =>
+ withTempPath { dir =>
+ val path = new Path(dir.toURI.toString, "test.parquet")
+ makeParquetFile(path, numValues, numGroups, dictionaryEnabled)
+ withParquetTable(path.toUri.toString, "tbl") {
+ Seq(128, numValues + 100).foreach { batchSize =>
+ withSQLConf(CometConf.COMET_BATCH_SIZE.key ->
batchSize.toString) {
+ (1 to 11).foreach { col =>
+ val aggregateFunctions =
+ List(s"COUNT(_$col)", s"MAX(_$col)", s"MIN(_$col)",
s"SUM(_$col)")
+ aggregateFunctions.foreach { function =>
+ val df1 = sql(s"SELECT $function OVER() FROM tbl")
+ checkSparkAnswerWithTol(df1, 1e-6)
+
+ val df2 = sql(s"SELECT $function OVER(order by _2) FROM
tbl")
+ checkSparkAnswerWithTol(df2, 1e-6)
+
+ val df3 = sql(s"SELECT $function OVER(order by _2 desc)
FROM tbl")
+ checkSparkAnswerWithTol(df3, 1e-6)
+
+ val df4 = sql(s"SELECT $function OVER(partition by _2
order by _2) FROM tbl")
+ checkSparkAnswerWithTol(df4, 1e-6)
+ }
+ }
+
+ // SUM doesn't work for Date type.
org.apache.spark.sql.AnalysisException will be thrown.
Review Comment:
Actually Spark throws Exception for Sum with Date type.
```
org.apache.spark.sql.AnalysisException:
[DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE] Cannot resolve "sum(_12)" due to data
type mismatch: Parameter 1 requires the "NUMERIC" or "ANSI INTERVAL" type,
however "_12" has the type "DATE".; line 1 pos 7;
'Project [unresolvedalias(sum(_12#11)
windowspecdefinition(unspecifiedframe$()), None)]
```
--
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]