ulysses-you commented on pull request #29749:
URL: https://github.com/apache/spark/pull/29749#issuecomment-696092667


   `ScalaUDF` has been checked in `ImplicitTypeCasts` just like extends 
`ImplicitCastInputTypes`. Here is some code from `ImplicitTypeCasts`.
   
   ```
         case e: ImplicitCastInputTypes if e.inputTypes.nonEmpty =>
           val children: Seq[Expression] = e.children.zip(e.inputTypes).map { 
case (in, expected) =>
             // If we cannot do the implicit cast, just use the original input.
             implicitCast(in, expected).getOrElse(in)
           }
           e.withNewChildren(children)
   
         case udf: ScalaUDF if udf.inputTypes.nonEmpty =>
           val children = udf.children.zip(udf.inputTypes).map { case (in, 
expected) =>
             // Currently Scala UDF will only expect `AnyDataType` at top 
level, so this trick works.
             // In the future we should create types like `AbstractArrayType`, 
so that Scala UDF can
             // accept inputs of array type of arbitrary element type.
             if (expected == AnyDataType) {
               in
             } else {
               implicitCast(
                 in,
                 udfInputToCastType(in.dataType, 
expected.asInstanceOf[DataType])
               ).getOrElse(in)
             }
   
           }
   ```


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

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