Skip to content

Commit 9e74ca6

Browse files
committed
review
1 parent b01bb8c commit 9e74ca6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ case class ExpandExec(
184184
(row, exprCodesWithIndices, inputVars.toSeq)
185185
}
186186

187-
def generateUpdateCode(exprCodes: Seq[(Int, ExprCode)]): String = {
187+
val updateCodes = switchCaseExprs.map { case (_, exprCodes, _) =>
188188
exprCodes.map { case (col, ev) =>
189189
s"""
190190
|${ev.code}
@@ -196,8 +196,7 @@ case class ExpandExec(
196196

197197
val splitThreshold = SQLConf.get.methodSplitThreshold
198198
val cases = if (switchCaseExprs.flatMap(_._2.map(_._2.code.length)).sum > splitThreshold) {
199-
switchCaseExprs.map { case (row, exprCodes, inputVars) =>
200-
val updateCode = generateUpdateCode(exprCodes)
199+
switchCaseExprs.zip(updateCodes).map { case ((row, _, inputVars), updateCode) =>
201200
val paramLength = CodeGenerator.calculateParamLengthFromExprValues(inputVars)
202201
val maybeSplitUpdateCode = if (CodeGenerator.isValidParamLength(paramLength)) {
203202
val switchCaseFunc = ctx.freshName("switchCaseCode")
@@ -222,10 +221,10 @@ case class ExpandExec(
222221
""".stripMargin
223222
}
224223
} else {
225-
switchCaseExprs.map { case (row, exprCodes, _) =>
224+
switchCaseExprs.map(_._1).zip(updateCodes).map { case (row, updateCode) =>
226225
s"""
227226
|case $row:
228-
| ${generateUpdateCode(exprCodes)}
227+
| $updateCode
229228
| break;
230229
""".stripMargin
231230
}

0 commit comments

Comments
 (0)