uros-b commented on code in PR #56889:
URL: https://github.com/apache/spark/pull/56889#discussion_r3497897441
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/aggregate/PercentileSuite.scala:
##########
@@ -113,6 +113,21 @@ class PercentileSuite extends SparkFunSuite {
}
}
+ test("SPARK-57557: Percentile and median support TIME type") {
+ // The return type mirrors the input TIME type, preserving precision.
+ assert(new Percentile(BoundReference(0, TimeType(), nullable = false),
Literal(0.5))
+ .dataType === TimeType())
+ assert(Median(BoundReference(0, TimeType(3), nullable = false)).dataType
=== TimeType(3))
+
+ // The exact median of two TIME values interpolates (continuous
distribution), returning the
+ // midpoint as Long nanos-of-day: median(00:00:00, 00:00:00.00000001) ->
00:00:00.000000005.
Review Comment:
Nit: misleading test comment. In PercentileSuite, the comment
median(00:00:00, 00:00:00.00000001) -> 00:00:00.000000005 uses 9-digit
(nanosecond) display, but TimeType max precision is microseconds (6), so that
literal isn't representable. The actual assertion (=== 5L on the internal Long)
is correct; just the comment's notation is 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]