spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject git commit: [SPARK-1819] [SQL] Fix GetField.nullable.
Date Thu, 15 May 2014 18:21:45 GMT
Repository: spark
Updated Branches:
  refs/heads/branch-1.0 7515367e3 -> f9eeddccb


[SPARK-1819] [SQL] Fix GetField.nullable.

`GetField.nullable` should be `true` not only when `field.nullable` is `true` but also when
`child.nullable` is `true`.

Author: Takuya UESHIN <ueshin@happy-camper.st>

Closes #757 from ueshin/issues/SPARK-1819 and squashes the following commits:

8781a11 [Takuya UESHIN] Modify a test to use named parameters.
5bfc77d [Takuya UESHIN] Fix GetField.nullable.

(cherry picked from commit 94c9d6f59859ebc77fae112c2c42c64b7a4d7f83)
Signed-off-by: Reynold Xin <rxin@apache.org>


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

Branch: refs/heads/branch-1.0
Commit: f9eeddccbd42064f5d1234b323ac74bb2a39e0aa
Parents: 7515367
Author: Takuya UESHIN <ueshin@happy-camper.st>
Authored: Thu May 15 11:21:33 2014 -0700
Committer: Reynold Xin <rxin@apache.org>
Committed: Thu May 15 11:21:39 2014 -0700

----------------------------------------------------------------------
 .../spark/sql/catalyst/expressions/complexTypes.scala  |  2 +-
 .../expressions/ExpressionEvaluationSuite.scala        | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/f9eeddcc/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypes.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypes.scala
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypes.scala
index 195ca2e..b6aeae9 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypes.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypes.scala
@@ -74,7 +74,7 @@ case class GetField(child: Expression, fieldName: String) extends UnaryExpressio
   type EvaluatedType = Any
 
   def dataType = field.dataType
-  override def nullable = field.nullable
+  override def nullable = child.nullable || field.nullable
   override def foldable = child.foldable
 
   protected def structType = child.dataType match {

http://git-wip-us.apache.org/repos/asf/spark/blob/f9eeddcc/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvaluationSuite.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvaluationSuite.scala
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvaluationSuite.scala
index 344d8a3..1132a30 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvaluationSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvaluationSuite.scala
@@ -364,6 +364,19 @@ class ExpressionEvaluationSuite extends FunSuite {
 
     checkEvaluation(GetField(BoundReference(2, AttributeReference("c", typeS)()), "a"), "aa",
row)
     checkEvaluation(GetField(Literal(null, typeS), "a"), null, row)
+
+    val typeS_notNullable = StructType(
+      StructField("a", StringType, nullable = false)
+        :: StructField("b", StringType, nullable = false) :: Nil
+    )
+
+    assert(GetField(BoundReference(2,
+      AttributeReference("c", typeS)()), "a").nullable === true)
+    assert(GetField(BoundReference(2,
+      AttributeReference("c", typeS_notNullable, nullable = false)()), "a").nullable ===
false)
+
+    assert(GetField(Literal(null, typeS), "a").nullable === true)
+    assert(GetField(Literal(null, typeS_notNullable), "a").nullable === true)
   }
 
   test("arithmetic") {


Mime
View raw message