spark git commit: [SPARK-11553][SQL] Primitive Row accessors should not convert null to default value

2015-11-16 Thread marmbrus
Repository: spark
Updated Branches:
  refs/heads/branch-1.6 3bd72eafc -> 6c8e0c0ff


[SPARK-11553][SQL] Primitive Row accessors should not convert null to default 
value

Invocation of getters for type extending AnyVal returns default value (if field 
value is null) instead of throwing NPE. Please check comments for SPARK-11553 
issue for more details.

Author: Bartlomiej Alberski 

Closes #9642 from alberskib/bugfix/SPARK-11553.

(cherry picked from commit 31296628ac7cd7be71e0edca335dc8604f62bb47)
Signed-off-by: Michael Armbrust 


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

Branch: refs/heads/branch-1.6
Commit: 6c8e0c0ff4fd3acbe0dbe7119920ee8b74d191dd
Parents: 3bd72ea
Author: Bartlomiej Alberski 
Authored: Mon Nov 16 15:14:38 2015 -0800
Committer: Michael Armbrust 
Committed: Mon Nov 16 15:14:48 2015 -0800

--
 .../main/scala/org/apache/spark/sql/Row.scala   | 32 -
 .../scala/org/apache/spark/sql/RowTest.scala| 20 +++
 .../local/NestedLoopJoinNodeSuite.scala | 36 
 3 files changed, 65 insertions(+), 23 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/spark/blob/6c8e0c0f/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala
--
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala
index 0f0f200..b14c66c 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala
@@ -191,7 +191,7 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getBoolean(i: Int): Boolean = getAs[Boolean](i)
+  def getBoolean(i: Int): Boolean = getAnyValAs[Boolean](i)
 
   /**
* Returns the value at position i as a primitive byte.
@@ -199,7 +199,7 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getByte(i: Int): Byte = getAs[Byte](i)
+  def getByte(i: Int): Byte = getAnyValAs[Byte](i)
 
   /**
* Returns the value at position i as a primitive short.
@@ -207,7 +207,7 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getShort(i: Int): Short = getAs[Short](i)
+  def getShort(i: Int): Short = getAnyValAs[Short](i)
 
   /**
* Returns the value at position i as a primitive int.
@@ -215,7 +215,7 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getInt(i: Int): Int = getAs[Int](i)
+  def getInt(i: Int): Int = getAnyValAs[Int](i)
 
   /**
* Returns the value at position i as a primitive long.
@@ -223,7 +223,7 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getLong(i: Int): Long = getAs[Long](i)
+  def getLong(i: Int): Long = getAnyValAs[Long](i)
 
   /**
* Returns the value at position i as a primitive float.
@@ -232,7 +232,7 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getFloat(i: Int): Float = getAs[Float](i)
+  def getFloat(i: Int): Float = getAnyValAs[Float](i)
 
   /**
* Returns the value at position i as a primitive double.
@@ -240,13 +240,12 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getDouble(i: Int): Double = getAs[Double](i)
+  def getDouble(i: Int): Double = getAnyValAs[Double](i)
 
   /**
* Returns the value at position i as a String object.
*
* @throws ClassCastException when data type does not match.
-   * @throws NullPointerException when value is null.
*/
   def getString(i: Int): String = getAs[String](i)
 
@@ -318,6 +317,8 @@ trait Row extends Serializable {
 
   /**
* Returns the value at position i.
+   * For primitive types if value is null it returns 'zero value' specific for 
primitive
+   * ie. 0 for Int - use isNullAt to ensure that value is not null
*
* @throws ClassCastException when data type does not match.
*/
@@ -325,6 +326,8 @@ trait Row extends Serializable {
 
   /**
* Returns the value of a gi

spark git commit: [SPARK-11553][SQL] Primitive Row accessors should not convert null to default value

2015-11-16 Thread marmbrus
Repository: spark
Updated Branches:
  refs/heads/master bcea0bfda -> 31296628a


[SPARK-11553][SQL] Primitive Row accessors should not convert null to default 
value

Invocation of getters for type extending AnyVal returns default value (if field 
value is null) instead of throwing NPE. Please check comments for SPARK-11553 
issue for more details.

Author: Bartlomiej Alberski 

Closes #9642 from alberskib/bugfix/SPARK-11553.


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

Branch: refs/heads/master
Commit: 31296628ac7cd7be71e0edca335dc8604f62bb47
Parents: bcea0bf
Author: Bartlomiej Alberski 
Authored: Mon Nov 16 15:14:38 2015 -0800
Committer: Michael Armbrust 
Committed: Mon Nov 16 15:14:38 2015 -0800

--
 .../main/scala/org/apache/spark/sql/Row.scala   | 32 -
 .../scala/org/apache/spark/sql/RowTest.scala| 20 +++
 .../local/NestedLoopJoinNodeSuite.scala | 36 
 3 files changed, 65 insertions(+), 23 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/spark/blob/31296628/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala
--
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala
index 0f0f200..b14c66c 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala
@@ -191,7 +191,7 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getBoolean(i: Int): Boolean = getAs[Boolean](i)
+  def getBoolean(i: Int): Boolean = getAnyValAs[Boolean](i)
 
   /**
* Returns the value at position i as a primitive byte.
@@ -199,7 +199,7 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getByte(i: Int): Byte = getAs[Byte](i)
+  def getByte(i: Int): Byte = getAnyValAs[Byte](i)
 
   /**
* Returns the value at position i as a primitive short.
@@ -207,7 +207,7 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getShort(i: Int): Short = getAs[Short](i)
+  def getShort(i: Int): Short = getAnyValAs[Short](i)
 
   /**
* Returns the value at position i as a primitive int.
@@ -215,7 +215,7 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getInt(i: Int): Int = getAs[Int](i)
+  def getInt(i: Int): Int = getAnyValAs[Int](i)
 
   /**
* Returns the value at position i as a primitive long.
@@ -223,7 +223,7 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getLong(i: Int): Long = getAs[Long](i)
+  def getLong(i: Int): Long = getAnyValAs[Long](i)
 
   /**
* Returns the value at position i as a primitive float.
@@ -232,7 +232,7 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getFloat(i: Int): Float = getAs[Float](i)
+  def getFloat(i: Int): Float = getAnyValAs[Float](i)
 
   /**
* Returns the value at position i as a primitive double.
@@ -240,13 +240,12 @@ trait Row extends Serializable {
* @throws ClassCastException when data type does not match.
* @throws NullPointerException when value is null.
*/
-  def getDouble(i: Int): Double = getAs[Double](i)
+  def getDouble(i: Int): Double = getAnyValAs[Double](i)
 
   /**
* Returns the value at position i as a String object.
*
* @throws ClassCastException when data type does not match.
-   * @throws NullPointerException when value is null.
*/
   def getString(i: Int): String = getAs[String](i)
 
@@ -318,6 +317,8 @@ trait Row extends Serializable {
 
   /**
* Returns the value at position i.
+   * For primitive types if value is null it returns 'zero value' specific for 
primitive
+   * ie. 0 for Int - use isNullAt to ensure that value is not null
*
* @throws ClassCastException when data type does not match.
*/
@@ -325,6 +326,8 @@ trait Row extends Serializable {
 
   /**
* Returns the value of a given fieldName.
+   * For primitive types if value is null it returns 'zero value' specific for 
primitive
+   *