Skip to content

Commit 44733f8

Browse files
committed
Add test to PushFoldableIntoBranchesSuite
1 parent c78882a commit 44733f8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/PushFoldableIntoBranchesSuite.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,17 @@ class PushFoldableIntoBranchesSuite
258258
EqualTo(CaseWhen(Seq((a, Literal(1)), (c, Literal(2))), None).cast(StringType), Literal("4")),
259259
CaseWhen(Seq((a, FalseLiteral), (c, FalseLiteral)), None))
260260
}
261+
262+
test("SPARK-33884: simplify CaseWhen when one clause is null and another is boolean") {
263+
val p = IsNull('a)
264+
val nullLiteral = Literal(null, BooleanType)
265+
assertEquivalent(EqualTo(
266+
CaseWhen(Seq((p, Literal.create(null, IntegerType))), Literal(1)),
267+
Literal(2)),
268+
And(p, nullLiteral))
269+
assertEquivalent(EqualTo(
270+
CaseWhen(Seq((p, Literal("str"))), Literal("1")).cast(IntegerType),
271+
Literal(2)),
272+
And(p, nullLiteral))
273+
}
261274
}

0 commit comments

Comments
 (0)