ala commented on a change in pull request #23789: [SPARK-26878]
QueryTest.compare() does not handle maps with array keys correctly
URL: https://github.com/apache/spark/pull/23789#discussion_r257517060
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala
##########
@@ -341,9 +341,11 @@ object QueryTest {
case (a: Array[_], b: Array[_]) =>
a.length == b.length && a.zip(b).forall { case (l, r) => compare(l, r)}
case (a: Map[_, _], b: Map[_, _]) =>
- val entries1 = a.iterator.toSeq.sortBy(_.toString())
- val entries2 = b.iterator.toSeq.sortBy(_.toString())
- compare(entries1, entries2)
+ a.size == b.size && a.keys.forall { aKey =>
+ b.keys.find(bKey => compare(aKey, bKey))
+ .map(bKey => compare(a(aKey), b(bKey)))
Review comment:
Nice.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]