Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19900#discussion_r155222185
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ScalaUDF.scala
 ---
    @@ -982,35 +982,30 @@ 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 expressionClassName = classOf[Expression].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((($expressionClassName)((($scalaUDFClassName)" +
    +        
s"references[$expressionIdx]).getChildren().apply($index))).dataType());")
       }
     
       override def doGenCode(
           ctx: CodegenContext,
           ev: ExprCode): ExprCode = {
    +    val thisClassName = this.getClass.getName
    +    val scalaUDF = ctx.freshName("scalaUDF")
    +    val scalaUDFRef = ctx.addReferenceMinorObj(this, thisClassName)
    --- End diff --
    
    ok we can keep it.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to