Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/master' into SPARK-33884
# Conflicts:
#	sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/PushFoldableIntoBranchesSuite.scala
#	sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/SimplifyConditionalSuite.scala
  • Loading branch information
wangyum committed Dec 24, 2020
commit 15c74ca9c63e80fb70e0d71ae89914c4b8f35272
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,17 @@ class PushFoldableIntoBranchesSuite
CaseWhen(Seq((a, FalseLiteral), (c, FalseLiteral)), None))
}

test("SPARK-33847: Remove the CaseWhen if elseValue is empty and other outputs are null") {
Seq(a, LessThan(Rand(1), Literal(0.5))).foreach { condition =>
assertEquivalent(
EqualTo(CaseWhen(Seq((condition, Literal.create(null, IntegerType)))), Literal(2)),
Literal.create(null, BooleanType))
assertEquivalent(
EqualTo(CaseWhen(Seq((condition, Literal("str")))).cast(IntegerType), Literal(2)),
Literal.create(null, BooleanType))
}
}

test("SPARK-33884: simplify CaseWhen when one clause is null and another is boolean") {
val p = IsNull('a)
val nullLiteral = Literal(null, BooleanType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ class SimplifyConditionalSuite extends PlanTest with ExpressionEvalHelper with P
LessThanOrEqual(Rand(0), UnresolvedAttribute("a")))
}

test("SPARK-33847: Remove the CaseWhen if elseValue is empty and other outputs are null") {
Seq(GreaterThan('a, 1), GreaterThan(Rand(0), 1)).foreach { condition =>
assertEquivalent(
CaseWhen((condition, Literal.create(null, IntegerType)) :: Nil, None),
Literal.create(null, IntegerType))
}
}

test("SPARK-33884: simplify CaseWhen when one clause is null and another is boolean") {
val p = IsNull('a)
val nullLiteral = Literal(null, BooleanType)
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.