You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ma...@apache.org on 2015/10/08 22:49:17 UTC

spark git commit: Revert [SPARK-8654] [SQL] Fix Analysis exception when using NULL IN

Repository: spark
Updated Branches:
  refs/heads/master af2a55448 -> a8226a9f1


Revert [SPARK-8654] [SQL] Fix Analysis exception when using NULL IN

This reverts commit dcbd58a929be0058b1cfa59b14898c4c428a7680 from #8983

Author: Michael Armbrust <mi...@databricks.com>

Closes #9034 from marmbrus/revert8654.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/a8226a9f
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/a8226a9f
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/a8226a9f

Branch: refs/heads/master
Commit: a8226a9f14e81c0b6712a30f1a60276200faebac
Parents: af2a554
Author: Michael Armbrust <mi...@databricks.com>
Authored: Thu Oct 8 13:49:10 2015 -0700
Committer: Michael Armbrust <mi...@databricks.com>
Committed: Thu Oct 8 13:49:10 2015 -0700

----------------------------------------------------------------------
 .../catalyst/analysis/HiveTypeCoercion.scala    | 10 ++--------
 .../sql/catalyst/analysis/AnalysisSuite.scala   | 21 --------------------
 2 files changed, 2 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/a8226a9f/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala
index 7192c93..87a3845 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala
@@ -304,10 +304,7 @@ object HiveTypeCoercion {
   }
 
   /**
-   * Convert the value and in list expressions to the common operator type
-   * by looking at all the argument types and finding the closest one that
-   * all the arguments can be cast to. When no common operator type is found
-   * an Analysis Exception is raised.
+   * Convert all expressions in in() list to the left operator type
    */
   object InConversion extends Rule[LogicalPlan] {
     def apply(plan: LogicalPlan): LogicalPlan = plan resolveExpressions {
@@ -315,10 +312,7 @@ object HiveTypeCoercion {
       case e if !e.childrenResolved => e
 
       case i @ In(a, b) if b.exists(_.dataType != a.dataType) =>
-        findWiderCommonType(i.children.map(_.dataType)) match {
-          case Some(finalDataType) => i.withNewChildren(i.children.map(Cast(_, finalDataType)))
-          case None => i
-        }
+        i.makeCopy(Array(a, b.map(Cast(_, a.dataType))))
     }
   }
 

http://git-wip-us.apache.org/repos/asf/spark/blob/a8226a9f/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
index 77a4765..820b336 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
@@ -135,25 +135,4 @@ class AnalysisSuite extends AnalysisTest {
     plan = testRelation.select(CreateStructUnsafe(Seq(a, (a + 1).as("a+1"))).as("col"))
     checkAnalysis(plan, plan)
   }
-
-  test("SPARK-8654: invalid CAST in NULL IN(...) expression") {
-    val plan = Project(Alias(In(Literal(null), Seq(Literal(1), Literal(2))), "a")() :: Nil,
-      LocalRelation()
-    )
-    assertAnalysisSuccess(plan)
-  }
-
-  test("SPARK-8654: different types in inlist but can be converted to a commmon type") {
-    val plan = Project(Alias(In(Literal(null), Seq(Literal(1), Literal(1.2345))), "a")() :: Nil,
-      LocalRelation()
-    )
-    assertAnalysisSuccess(plan)
-  }
-
-  test("SPARK-8654: check type compatibility error") {
-    val plan = Project(Alias(In(Literal(null), Seq(Literal(true), Literal(1))), "a")() :: Nil,
-      LocalRelation()
-    )
-    assertAnalysisError(plan, Seq("data type mismatch: Arguments must be same type"))
-  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org