Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ abstract class HashMapGenerator(

dataType match {
case BooleanType => hashInt(s"$input ? 1 : 0")
case ByteType | ShortType | IntegerType | DateType => hashInt(input)
case LongType | TimestampType => hashLong(input)
case ByteType | ShortType | IntegerType | DateType | YearMonthIntervalType => hashInt(input)
case LongType | TimestampType | DayTimeIntervalType => hashLong(input)
case FloatType => hashInt(s"Float.floatToIntBits($input)")
case DoubleType => hashLong(s"Double.doubleToLongBits($input)")
case d: DecimalType =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,13 @@ class DataFrameAggregateSuite extends QueryTest
val avgDF4 = df3.groupBy($"class").agg(avg($"year-month"), avg($"day-time"))
checkAnswer(avgDF4, Nil)
}

test("SPARK-35412: groupBy of year-month/day-time intervals should work") {
val df1 = Seq(Duration.ofDays(1)).toDF("a").groupBy("a").count()
checkAnswer(df1, Row(Duration.ofDays(1), 1))
val df2 = Seq(Period.ofYears(1)).toDF("a").groupBy("a").count()
checkAnswer(df2, Row(Period.ofYears(1), 1))
}
}

case class B(c: Option[Double])
Expand Down