aboutsummaryrefslogtreecommitdiff
path: root/sql/core
diff options
context:
space:
mode:
authorJosh Rosen <joshrosen@databricks.com>2015-08-28 11:51:42 -0700
committerMichael Armbrust <michael@databricks.com>2015-08-28 11:51:42 -0700
commitd3f87dc39480f075170817bbd00142967a938078 (patch)
tree7f28c76093c43f44d6c3e2d5e5b3e7f12e00fd80 /sql/core
parent499e8e154bdcc9d7b2f685b159e0ddb4eae48fe4 (diff)
downloadspark-d3f87dc39480f075170817bbd00142967a938078.tar.gz
spark-d3f87dc39480f075170817bbd00142967a938078.tar.bz2
spark-d3f87dc39480f075170817bbd00142967a938078.zip
[SPARK-10325] Override hashCode() for public Row
This commit fixes an issue where the public SQL `Row` class did not override `hashCode`, causing it to violate the hashCode() + equals() contract. To fix this, I simply ported the `hashCode` implementation from the 1.4.x version of `Row`. Author: Josh Rosen <joshrosen@databricks.com> Closes #8500 from JoshRosen/SPARK-10325 and squashes the following commits: 51ffea1 [Josh Rosen] Override hashCode() for public Row.
Diffstat (limited to 'sql/core')
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/RowSuite.scala9
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/RowSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/RowSuite.scala
index 795d4e983f..77ccd6f775 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/RowSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/RowSuite.scala
@@ -85,4 +85,13 @@ class RowSuite extends SparkFunSuite with SharedSQLContext {
val r2 = Row(Double.NaN)
assert(r1 === r2)
}
+
+ test("equals and hashCode") {
+ val r1 = Row("Hello")
+ val r2 = Row("Hello")
+ assert(r1 === r2)
+ assert(r1.hashCode() === r2.hashCode())
+ val r3 = Row("World")
+ assert(r3.hashCode() != r1.hashCode())
+ }
}