Skip to content
Prev Previous commit
Close gap in ExpandExec
  • Loading branch information
bersprockets committed Jan 13, 2019
commit b1afb3a7bb0e1a67ce12c43ac545650e54a37e7c
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ case class ExpandExec(
// Part 1: declare variables for each column
// If a column has the same value for all output rows, then we also generate its computation
// right after declaration. Otherwise its value is computed in the part 2.
lazy val attributeSeq: AttributeSeq = child.output
val outputColumns = output.indices.map { col =>
val firstExpr = projections.head(col)
if (sameOutput(col)) {
// This column is the same across all output rows. Just generate code for it here.
BindReferences.bindReference(firstExpr, child.output).genCode(ctx)
BindReferences.bindReference(firstExpr, attributeSeq).genCode(ctx)
} else {
val isNull = ctx.freshName("isNull")
val value = ctx.freshName("value")
Expand All @@ -168,7 +169,6 @@ case class ExpandExec(
// Part 2: switch/case statements
val cases = projections.zipWithIndex.map { case (exprs, row) =>
var updateCode = ""
val attributeSeq: AttributeSeq = child.output
for (col <- exprs.indices) {
if (!sameOutput(col)) {
val ev = BindReferences.bindReference(exprs(col), attributeSeq).genCode(ctx)
Expand Down