Github user mgaido91 commented on a diff in the pull request:
https://github.com/apache/spark/pull/19900#discussion_r155239094
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ScalaUDF.scala
---
@@ -982,35 +982,29 @@ case class ScalaUDF(
// scalastyle:on line.size.limit
- // Generate codes used to convert the arguments to Scala type for
user-defined functions
- private[this] def genCodeForConverter(ctx: CodegenContext, index: Int):
String = {
- val converterClassName = classOf[Any => Any].getName
- val typeConvertersClassName = CatalystTypeConverters.getClass.getName
+ ".MODULE$"
- val expressionClassName = classOf[Expression].getName
- val scalaUDFClassName = classOf[ScalaUDF].getName
+ private val converterClassName = classOf[Any => Any].getName
+ private val scalaUDFClassName = classOf[ScalaUDF].getName
+ private val typeConvertersClassName =
CatalystTypeConverters.getClass.getName + ".MODULE$"
+ // Generate codes used to convert the arguments to Scala type for
user-defined functions
+ private[this] def genCodeForConverter(ctx: CodegenContext, index: Int):
(String, String) = {
val converterTerm = ctx.freshName("converter")
val expressionIdx = ctx.references.size - 1
- ctx.addMutableState(converterClassName, converterTerm,
- s"$converterTerm = ($converterClassName)$typeConvertersClassName" +
-
s".createToScalaConverter(((${expressionClassName})((($scalaUDFClassName)" +
-
s"references[$expressionIdx]).getChildren().apply($index))).dataType());")
- converterTerm
+ (converterTerm,
+ s"$converterClassName $converterTerm =
($converterClassName)$typeConvertersClassName" +
+ s".createToScalaConverter(((Expression)((($scalaUDFClassName)" +
+
s"references[$expressionIdx]).getChildren().apply($index))).dataType());")
}
override def doGenCode(
ctx: CodegenContext,
ev: ExprCode): ExprCode = {
+ val thisClassName = this.getClass.getName
--- End diff --
yes, thanks, nice catch! I am updating it. Thank you.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]