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

    https://github.com/apache/spark/pull/22066#discussion_r209426589
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
 ---
    @@ -404,21 +404,26 @@ abstract class HashExpression[E] extends Expression {
           input: String,
           result: String,
           fields: Array[StructField]): String = {
    +    val tmpInput = ctx.freshName("input")
         val fieldsHash = fields.zipWithIndex.map { case (field, index) =>
    -      nullSafeElementHash(input, index.toString, field.nullable, 
field.dataType, result, ctx)
    +      nullSafeElementHash(tmpInput, index.toString, field.nullable, 
field.dataType, result, ctx)
         }
         val hashResultType = CodeGenerator.javaType(dataType)
    -    ctx.splitExpressions(
    +    val code = ctx.splitExpressions(
           expressions = fieldsHash,
           funcName = "computeHashForStruct",
    -      arguments = Seq("InternalRow" -> input, hashResultType -> result),
    +      arguments = Seq("InternalRow" -> tmpInput, hashResultType -> result),
           returnType = hashResultType,
           makeSplitFunction = body =>
             s"""
                |$body
                |return $result;
              """.stripMargin,
           foldFunctions = _.map(funcCall => s"$result = 
$funcCall;").mkString("\n"))
    +    s"""
    +       |final InternalRow $tmpInput = $input;
    --- End diff --
    
    Note: we can avoid creating a new variable if the `input` is already a 
variable. I think this can be done after we fully adopt the new codegen infra 
from @viirya 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to