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

    https://github.com/apache/spark/pull/11484#discussion_r54996591
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/WholeStageCodegen.scala 
---
    @@ -125,14 +133,27 @@ trait CodegenSupport extends SparkPlan {
           row: String = null): String = {
         ctx.freshNamePrefix = variablePrefix
         if (row != null) {
    -      ctx.currentVars = null
    -      ctx.INPUT_ROW = row
    -      val evals = child.output.zipWithIndex.map { case (attr, i) =>
    -        BoundReference(i, attr.dataType, attr.nullable).gen(ctx)
    +      val evals: Seq[ExprCode] = if (!consumeUnsafeRow) {
    +        // If this SparkPlan can't consume UnsafeRow and there is an 
UnsafeRow,
    +        // we extract the columns from the row and call doConsume.
    +        ctx.currentVars = null
    +        ctx.INPUT_ROW = row
    +        child.output.zipWithIndex.map { case (attr, i) =>
    +          BoundReference(i, attr.dataType, attr.nullable).gen(ctx)
    +        }
    +      } else {
    +        // If this SparkPlan consumes UnsafeRow and there is an UnsafeRow,
    +        // we don't need to unpack variables from the row.
    +        Seq.empty
    +      }
    +      val evalCode = if (evals.isEmpty) {
    +        ""
    +      } else {
    +        s"${evals.map(_.code).mkString("\n")}"
           }
           s"""
    -         | ${evals.map(_.code).mkString("\n")}
    -         | ${doConsume(ctx, evals)}
    +         | $evalCode
    +         | ${doConsume(ctx, evals, row)}
            """.stripMargin
         } else {
           doConsume(ctx, input)
    --- End diff --
    
    pass `null` here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to