Github user kiszk commented on a diff in the pull request:
https://github.com/apache/spark/pull/18641#discussion_r150845392
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala
---
@@ -262,37 +262,91 @@ case class CaseWhenCodegen(
// }
// }
// }
+
+ val isNull = ctx.freshName("caseWhenIsNull")
+ val value = ctx.freshName("caseWhenValue")
+
val cases = branches.map { case (condExpr, valueExpr) =>
--- End diff --
For `CaseWhen`, the code bloat occurs in one case class. The
`CaseWhenCodegen.doGenCode` can generate deeply-nested `if-then-else`
statements as above in the comment. Each element in `cases` has only a
`if-then`. Thus, it is not possible to insert code check here. Since `And` and
`Or` generates deeply nested `if-then-else` by calling `doGenCode` many times,
to check code size here works well.
[This
line](https://github.com/apache/spark/pull/18641/files#diff-a966ee88604a834221e82916ec051d7dR286)
generates the nested `if-then-else`. Thus, after this line, code size check is
performed.
What do you think?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]