You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/06/24 12:51:33 UTC

[GitHub] [spark] cloud-fan commented on a diff in pull request #36965: [WIP][SPARK-39567][SQL] Support ANSI intervals in the percentile functions

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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org