srowen commented on code in PR #37771:
URL: https://github.com/apache/spark/pull/37771#discussion_r962166373
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/ArrayBasedMapBuilderSuite.scala:
##########
@@ -142,4 +142,36 @@ class ArrayBasedMapBuilderSuite extends SparkFunSuite with
SQLHelper {
Map(new GenericArrayData(Seq(1, 1)) -> 3, new GenericArrayData(Seq(2,
2)) -> 2))
}
}
+
+ test("SPARK-40315: simple equal() and hashCode() semantics") {
+ val dataToAdd: Map[Int, Int] = Map(0 -> -7, 1 -> 3, 10 -> 4, 20 -> 5)
+ val builder1 = new ArrayBasedMapBuilder(IntegerType, IntegerType)
+ val builder2 = new ArrayBasedMapBuilder(IntegerType, IntegerType)
+ val builder3 = new ArrayBasedMapBuilder(IntegerType, IntegerType)
+ dataToAdd.foreach { case (key, value) =>
+ builder1.put(key, value)
+ builder2.put(key, value)
+ // Replace the value by something slightly different in builder3 for one
of the keys.
+ if (key == 20) {
+ builder3.put(key, value - 1)
+ } else {
+ builder3.put(key, value)
+ }
+ }
+ val arrayBasedMapData1 = builder1.build()
+ val arrayBasedMapData2 = builder2.build()
+ val arrayBasedMapData3 = builder3.build()
+
+ // We expect two objects to be equal and to have the same hashCode if they
have the same
+ // elements.
+ assert(arrayBasedMapData1 == arrayBasedMapData2)
Review Comment:
I think this is redundant with the next line? they aren't the same object,
so this isn't ref equality
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]