Skip to content

Commit a8226a9

Browse files
committed
Revert [SPARK-8654] [SQL] Fix Analysis exception when using NULL IN
This reverts commit dcbd58a from apache#8983 Author: Michael Armbrust <[email protected]> Closes apache#9034 from marmbrus/revert8654.
1 parent af2a554 commit a8226a9

File tree

2 files changed

+2
-29
lines changed

2 files changed

+2
-29
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,21 +304,15 @@ object HiveTypeCoercion {
304304
}
305305

306306
/**
307-
* Convert the value and in list expressions to the common operator type
308-
* by looking at all the argument types and finding the closest one that
309-
* all the arguments can be cast to. When no common operator type is found
310-
* an Analysis Exception is raised.
307+
* Convert all expressions in in() list to the left operator type
311308
*/
312309
object InConversion extends Rule[LogicalPlan] {
313310
def apply(plan: LogicalPlan): LogicalPlan = plan resolveExpressions {
314311
// Skip nodes who's children have not been resolved yet.
315312
case e if !e.childrenResolved => e
316313

317314
case i @ In(a, b) if b.exists(_.dataType != a.dataType) =>
318-
findWiderCommonType(i.children.map(_.dataType)) match {
319-
case Some(finalDataType) => i.withNewChildren(i.children.map(Cast(_, finalDataType)))
320-
case None => i
321-
}
315+
i.makeCopy(Array(a, b.map(Cast(_, a.dataType))))
322316
}
323317
}
324318

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,4 @@ class AnalysisSuite extends AnalysisTest {
135135
plan = testRelation.select(CreateStructUnsafe(Seq(a, (a + 1).as("a+1"))).as("col"))
136136
checkAnalysis(plan, plan)
137137
}
138-
139-
test("SPARK-8654: invalid CAST in NULL IN(...) expression") {
140-
val plan = Project(Alias(In(Literal(null), Seq(Literal(1), Literal(2))), "a")() :: Nil,
141-
LocalRelation()
142-
)
143-
assertAnalysisSuccess(plan)
144-
}
145-
146-
test("SPARK-8654: different types in inlist but can be converted to a commmon type") {
147-
val plan = Project(Alias(In(Literal(null), Seq(Literal(1), Literal(1.2345))), "a")() :: Nil,
148-
LocalRelation()
149-
)
150-
assertAnalysisSuccess(plan)
151-
}
152-
153-
test("SPARK-8654: check type compatibility error") {
154-
val plan = Project(Alias(In(Literal(null), Seq(Literal(true), Literal(1))), "a")() :: Nil,
155-
LocalRelation()
156-
)
157-
assertAnalysisError(plan, Seq("data type mismatch: Arguments must be same type"))
158-
}
159138
}

0 commit comments

Comments
 (0)