Skip to content

Commit b1afb3a

Browse files
committed
Close gap in ExpandExec
1 parent 686e7b5 commit b1afb3a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/ExpandExec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,12 @@ case class ExpandExec(
145145
// Part 1: declare variables for each column
146146
// If a column has the same value for all output rows, then we also generate its computation
147147
// right after declaration. Otherwise its value is computed in the part 2.
148+
lazy val attributeSeq: AttributeSeq = child.output
148149
val outputColumns = output.indices.map { col =>
149150
val firstExpr = projections.head(col)
150151
if (sameOutput(col)) {
151152
// This column is the same across all output rows. Just generate code for it here.
152-
BindReferences.bindReference(firstExpr, child.output).genCode(ctx)
153+
BindReferences.bindReference(firstExpr, attributeSeq).genCode(ctx)
153154
} else {
154155
val isNull = ctx.freshName("isNull")
155156
val value = ctx.freshName("value")
@@ -168,7 +169,6 @@ case class ExpandExec(
168169
// Part 2: switch/case statements
169170
val cases = projections.zipWithIndex.map { case (exprs, row) =>
170171
var updateCode = ""
171-
val attributeSeq: AttributeSeq = child.output
172172
for (col <- exprs.indices) {
173173
if (!sameOutput(col)) {
174174
val ev = BindReferences.bindReference(exprs(col), attributeSeq).genCode(ctx)

0 commit comments

Comments
 (0)