Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18972#discussion_r150282403
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
 ---
    @@ -809,6 +809,36 @@ class CodegenContext {
       }
     
       /**
    +   * Wrap the generated code of expression, which was created from a row 
object in INPUT_ROW,
    +   * by a function. ev,isNull and ev.value are passed by global variables
    +   *
    +   * @param ev the code to evaluate expressions.
    +   * @param dataType the data type of ev.value.
    +   * @param baseFuncName the split function name base.
    +   */
    +  def createAndAddFunction(
    +      ev: ExprCode,
    +      dataType: DataType,
    +      baseFuncName: String): (String, String, String) = {
    +    val globalIsNull = freshName("isNull")
    +    addMutableState("boolean", globalIsNull, s"$globalIsNull = false;")
    +    val globalValue = freshName("value")
    +    addMutableState(javaType(dataType), globalValue,
    +      s"$globalValue = ${defaultValue(dataType)};")
    +    val funcName = freshName(baseFuncName)
    +    val funcBody =
    +      s"""
    +         |private void $funcName(InternalRow ${INPUT_ROW}) {
    --- End diff --
    
    Yes, it works only if `ctx.currentVars == null`.  
    We will follow to support the whole stage codegen as follow-up in other PRs.


---

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

Reply via email to