cloud-fan commented on code in PR #50823:
URL: https://github.com/apache/spark/pull/50823#discussion_r2080665514
##########
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:
> if child.output was [a#1, b#2] but requiredChildOutput was [b#2, a#1]
This will not happen according to how we generate `requiredChildOutput`
today. The change here is to make sure the data matches its declared schema.
Even if this case happens (`[a#1, b#2]` vs `[b#2, a#1]`), we have to do a
projection to reorder the columns.
--
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]