dtenedor commented on a change in pull request #35735:
URL: https://github.com/apache/spark/pull/35735#discussion_r820987567



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/HistogramNumeric.scala
##########
@@ -125,7 +125,21 @@ case class HistogramNumeric(
     } else {
       val result = (0 until buffer.getUsedBins).map { index =>
         val coord = buffer.getBin(index)
-        InternalRow.apply(coord.x, coord.y)
+        // The 'coord.x' and 'coord.y' have double type here. If the 
expression is expected to
+        // return a result of double type, this is sufficient. Otherwise, we 
need to internally
+        // convert these values to the expected result type, for cases like 
timestamps and intervals
+        // which are valid inputs to the numeric histogram aggregate function.
+        val result: Any = left.dataType match {
+          case ByteType => coord.x.toByte
+          case IntegerType | DateType | _: YearMonthIntervalType =>
+            coord.x.toInt

Review comment:
       Good idea, done. Also added a similar example in a comment for the 
baseline code path when the new SQLConf is turned off.




-- 
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]

Reply via email to