mihailom-db commented on code in PR #46991:
URL: https://github.com/apache/spark/pull/46991#discussion_r1640315013
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CallMethodViaReflection.scala:
##########
@@ -59,11 +62,11 @@ import org.apache.spark.util.Utils
since = "2.0.0",
group = "misc_funcs")
case class CallMethodViaReflection(
- children: Seq[Expression],
- failOnError: Boolean = true)
+ children: Seq[Expression],
+ failOnError: Boolean = true)
extends Nondeterministic
- with CodegenFallback
- with QueryErrorsBase {
+ with CodegenFallback
+ with QueryErrorsBase {
Review Comment:
nit: style as well
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala:
##########
@@ -208,6 +208,50 @@ class CollationSuite extends DatasourceV2SQLBase with
AdaptiveSparkPlanHelper {
}
}
+ test("[SPARK-48472] Enable reflect expressions with collated strings") {
Review Comment:
lets move this to `CollationSQLExpressionsSuite` and follow the pattern
there.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CallMethodViaReflection.scala:
##########
@@ -229,10 +234,13 @@ object CallMethodViaReflection {
} else {
// Argument type must match. That is, either the method's argument
type matches one of the
// acceptable types defined in typeMapping, or it is a super type of
the acceptable types.
- candidateTypes.zip(argTypes).forall { case (candidateType, argType) =>
+ candidateTypes.zip(argTypes).forall { case (candidateType, argType)
+ if !argType.isInstanceOf[StringType] =>
typeMapping(argType).exists(candidateType.isAssignableFrom)
+ case _ => true
Review Comment:
```suggestion
case _ => candidateType.isAssignableFrom(classOf[String])
```
I believe this should not be only true. This should be reproducible from
passing something that is a string to a function that expects e.g. integer.
--
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]