cloud-fan commented on code in PR #36965:
URL: https://github.com/apache/spark/pull/36965#discussion_r906031799
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/percentiles.scala:
##########
@@ -57,17 +57,24 @@ abstract class PercentileBase extends
TypedImperativeAggregate[OpenHashMap[AnyRe
// Returns null for empty inputs
override def nullable: Boolean = true
- override lazy val dataType: DataType = percentageExpression.dataType match {
- case _: ArrayType => ArrayType(DoubleType, false)
- case _ => DoubleType
+ // The result type is the same as the input type.
+ override lazy val dataType: DataType = {
+ val resultType = child.dataType match {
+ case it: AnsiIntervalType => it
+ case _ => DoubleType
+ }
+ if (returnPercentileArray) ArrayType(resultType, false) else resultType
}
override def inputTypes: Seq[AbstractDataType] = {
val percentageExpType = percentageExpression.dataType match {
case _: ArrayType => ArrayType(DoubleType, false)
case _ => DoubleType
}
- Seq(NumericType, percentageExpType, IntegralType)
+ Seq(
+ TypeCollection(NumericType, YearMonthIntervalType, DayTimeIntervalType),
Review Comment:
```suggestion
TypeCollection(NumericType, AnsiIntervalType),
```
--
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]