uros-b commented on code in PR #56971:
URL: https://github.com/apache/spark/pull/56971#discussion_r3524902932
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/NullExpressionsSuite.scala:
##########
@@ -207,10 +207,21 @@ class NullExpressionsSuite extends SparkFunSuite with
ExpressionEvalHelper {
test("SPARK-22705: Coalesce should use less global variables") {
val ctx = new CodegenContext()
- Coalesce(Seq(Literal("a"), Literal("b"))).genCode(ctx)
+ // Use three children so that the general do-while codegen path is
exercised: the two-argument
+ // form with a non-nullable pure fallback is now special-cased to a
ternary with no global
+ // state (covered by the test below).
+ Coalesce(Seq(Literal("a"), Literal("b"), Literal("c"))).genCode(ctx)
assert(ctx.inlinedMutableStates.size == 1)
}
+ test("Coalesce with a non-nullable pure fallback compiles to a ternary with
no global state") {
Review Comment:
Noting a minor test coverage gap: the new fast-path test uses only Literal
inputs and StringType. The motivating hot path is coalesce(nullable_column, 0)
where the first arg is a BoundReference (a distinct codegen path via
currentVars lookup, not ExprCode.forNonNullValue) and the fallback is a
primitive.
Adding a BoundReference-through-a-row case (both null and non-null branches,
e.g. checkEvaluation(Coalesce(Seq(BoundReference(0, IntegerType, nullable =
true), Literal(0))), 42, InternalRow(42))) would pin the actual motivating path.
--
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]