metanil commented on code in PR #59760:
URL: https://github.com/apache/spark/pull/59760#discussion_r4433918256
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/TransformExpression.scala:
##########
@@ -202,4 +333,60 @@ object TransformExpression {
case t: TransformExpression => t.reducedWith.isDefined
case _ => false
}
+
+ /**
+ * `argument` at `declaredType`, or `None` when the function could not take
it. See
+ * [[TransformExpression.evaluableFunction]].
+ *
+ * An argument goes as it is when it is stored the way the declared type is
(`storedAlike`),
+ * which is how a function read it before this check. A narrower integral
argument is held as
+ * another JVM type, so it is cast. Anything else is refused, a `DATE`
against a `TIMESTAMP` in
+ * particular, whose cast takes the session time zone.
+ */
+ private def atDeclaredType(argument: Expression, declaredType: DataType):
Option[Expression] =
+ (argument.dataType, declaredType) match {
+ case (argumentType, _) if storedAlike(argumentType, declaredType, nested
= false) =>
+ Some(argument)
+ case (argumentType: IntegralType, declared: IntegralType)
Review Comment:
Good point. Done in 53d75f325d6: any numeric argument narrower than declared
(`legalNumericPrecedence`) is now cast, not just integral ones, so `INT`
against `DOUBLE` gives the same value Java's widening gave the `invoke` on
master. It's covered in `TransformExpressionSuite` and `ShuffleSpecSuite`, plus
an end-to-end `INT` column with a `bucket` declaring `(INT, DOUBLE)` that keeps
its plan. I added it to the description too.
--
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]