Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/7593#discussion_r35286283
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala
---
@@ -832,4 +832,15 @@ class DataFrameSuite extends QueryTest with
SQLTestUtils {
assert(e3.getMessage.contains("Inserting into an RDD-based table is
not allowed."))
}
}
+
+ test("sort with non-deterministic expressions") {
+ import org.apache.spark.util.random.XORShiftRandom
+
+ val seed = 33
+ val df = (1 to 100).map(Tuple1.apply).toDF("i")
+ val random = new XORShiftRandom(seed)
+ val expected = (1 to 100).map(_ ->
random.nextDouble()).sortBy(_._2).map(_._1)
+ val actual = df.sort(rand(seed)).collect().map(_.getInt(0))
+ assert(expected === actual)
--- End diff --
This is guaranteed by `CheckAnalysis`, now `Sort` is marked as resolved
only when its ordering expressions are all `AttributeReference`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]