maropu commented on a change in pull request #26680: [SPARK-30047][SQL]
HashAggregate support for interval value aggs
URL: https://github.com/apache/spark/pull/26680#discussion_r351030841
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala
##########
@@ -942,4 +943,18 @@ class DataFrameAggregateSuite extends QueryTest with
SharedSparkSession {
assert(error.message.contains("function count_if requires boolean type"))
}
}
+
+ test("calendar interval agg support hash aggregate") {
+ val df1 = Seq((1, "1 day"), (2, "2 day"), (3, "3 day"), (3,
null)).toDF("a", "b")
+ val df2 = df1.select(avg('b cast CalendarIntervalType))
+ checkAnswer(df2, Row(new CalendarInterval(0, 2, 0)) :: Nil)
+
assert(df2.queryExecution.executedPlan.find(_.isInstanceOf[HashAggregateExec]).isDefined)
+ val df3 = df1.groupBy('a).agg(avg('b cast CalendarIntervalType))
+ checkAnswer(df3,
+ Row(1, new CalendarInterval(0, 1, 0)) ::
+ Row(2, new CalendarInterval(0, 2, 0)) ::
+ Row(3, new CalendarInterval(0, 3, 0)) :: Nil)
+
assert(df3.queryExecution.executedPlan.find(_.isInstanceOf[HashAggregateExec]).isDefined)
+
Review comment:
nit: remove this blank
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]