stevomitric commented on code in PR #56612:
URL: https://github.com/apache/spark/pull/56612#discussion_r3448450890
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/ExpressionTypeCheckingSuite.scala:
##########
@@ -408,6 +408,20 @@ class ExpressionTypeCheckingSuite extends SparkFunSuite
with SQLHelper with Quer
}
}
+ test("SPARK-57103: max_by/min_by accept a nanosecond ordering and preserve
the value type") {
+ // MaxBy/MinBy gate only on the ordering expression's orderability; a
nanosecond ordering is an
+ // orderable AtomicType (SPARK-57103). The value expression is
unrestricted, and the result type
+ // is the value's type, so a nanosecond value is returned with its
precision preserved.
+ Seq(TimestampNTZNanosType(9), TimestampLTZNanosType(7)).foreach { dt =>
+ val v = AttributeReference("v", dt)()
+ val ord = AttributeReference("ord", dt)()
+ assert(MaxBy(v, ord).checkInputDataTypes() ==
TypeCheckResult.TypeCheckSuccess)
+ assert(MinBy(v, ord).checkInputDataTypes() ==
TypeCheckResult.TypeCheckSuccess)
+ assert(MaxBy(v, ord).dataType == dt)
+ assert(MinBy(v, ord).dataType == dt)
+ }
Review Comment:
Done - all three now use the functions.max_by/min_by(Column, Column) API
--
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]