cloud-fan commented on a change in pull request #26173: [SPARK-29503][SQL] Copy
result row from RowWriter in GenerateUnsafeProjection when the expression is
lambdaFunction in MapObject
URL: https://github.com/apache/spark/pull/26173#discussion_r336848783
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateUnsafeProjection.scala
##########
@@ -310,8 +312,19 @@ object GenerateUnsafeProjection extends
CodeGenerator[Seq[Expression], UnsafePro
|$evalSubexpr
|$writeExpressions
""".stripMargin
+
+ val runInsideLoop = expressions.exists {
+ case _: LambdaVariable => true
+ case _ => false
+ }
+ val extractValueCode = if (runInsideLoop) {
+ s"$rowWriter.getRow().copy()"
+ } else {
+ s"$rowWriter.getRow()"
+ }
Review comment:
Agree that we should fix `CodegenContext.generateExpressionAndCopyIfUnsafe`.
To simplify codegen, maybe we can add `copyUnsafeData` to
`InternalRow`/`ArrayData`/`MapData`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]