Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/19321#discussion_r140647683
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/ApproximatePercentile.scala
---
@@ -134,7 +141,18 @@ case class ApproximatePercentile(
}
override def eval(buffer: PercentileDigest): Any = {
- val result = buffer.getPercentiles(percentages)
+ val doubleResult = buffer.getPercentiles(percentages)
+ val result = child.dataType match {
+ case DateType => doubleResult.map(_.toInt)
+ case TimestampType => doubleResult.map(_.toLong)
+ case ByteType => doubleResult.map(_.toByte)
+ case ShortType => doubleResult.map(_.toShort)
+ case IntegerType => doubleResult.map(_.toInt)
+ case LongType => doubleResult.map(_.toLong)
+ case FloatType => doubleResult.map(_.toFloat)
+ case DoubleType => doubleResult
+ case _: DecimalType => doubleResult.map(Decimal(_))
--- End diff --
Add
```Scala
case other: DataType =>
throw new UnsupportedOperationException(s"Unexpected data type
$other")
```
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]