harshmotw-db commented on code in PR #50823:
URL: https://github.com/apache/spark/pull/50823#discussion_r2080547202


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/GenerateExec.scala:
##########
@@ -86,12 +86,16 @@ case class GenerateExec(
       val generatorNullRow = new 
GenericInternalRow(generator.elementSchema.length)
       val rows = if (requiredChildOutput.nonEmpty) {
 
-        val pruneChildForResult: InternalRow => InternalRow =
-          if (child.outputSet == AttributeSet(requiredChildOutput)) {
+        val pruneChildForResult: InternalRow => InternalRow = {
+          // The declared output of this operator is `requiredChildOutput ++ 
generatorOutput`.
+          // If `child.output` is different from `requiredChildOutput`, we 
must do an projection
+          // to adjust the child output and make sure the final result matches 
the declared output.
+          if (child.output == requiredChildOutput) {

Review Comment:
   I'm wondering if this could cause regressions. Is it possible that some 
cases were rightfully going to be identity earlier but are not identity anymore?
   
   For example, if child.output was `[a#1, b#2]` but requiredChildOutput was 
`[b#2, a#1]`, it wouldn't pass through identity anymore but earlier it would 
right?
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to