Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,13 @@ case class CaseWhen(branches: Seq[Expression]) extends Expression {
false
} else {
val allCondBooleans = predicates.forall(_.dataType == BooleanType)
val dataTypesEqual = values.map(_.dataType).distinct.size <= 1
// both then and else val should be considered.
val dataTypesEqual = (values ++ elseValue).map(_.dataType).distinct.size <= 1
allCondBooleans && dataTypesEqual
}
}

/** Written in imperative fashion for performance considerations. Same for CaseKeyWhen. */
/** Written in imperative fashion for performance considerations. */
override def eval(input: Row): Any = {
val len = branchesArr.length
var i = 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NULL
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NULL
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NULL
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NULL
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NULL
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ class HiveTypeCoercionSuite extends HiveComparisonTest {
}
}

val nullVal = "null"
baseTypes.init.foreach { i =>
createQueryTest(s"case when then $i else $nullVal end ", s"SELECT case when true then $i else $nullVal end FROM src limit 1")
createQueryTest(s"case when then $nullVal else $i end ", s"SELECT case when true then $nullVal else $i end FROM src limit 1")
}

test("[SPARK-2210] boolean cast on boolean value should be removed") {
val q = "select cast(cast(key=0 as boolean) as boolean) from src"
val project = TestHive.sql(q).queryExecution.executedPlan.collect { case e: Project => e }.head
Expand Down