Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/19828#discussion_r153243250
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
---
@@ -2757,4 +2759,43 @@ class SQLQuerySuite extends QueryTest with
SharedSQLContext {
}
}
}
+
+ test("repartitionByRange") {
+ val data1d = Random.shuffle(0.to(9))
+ val data2d = data1d.map(i => (i, data1d.size - i))
+
+ checkAnswer(
+ data1d.toDF("val").repartitionByRange(data1d.size, $"val".asc)
+ .select(spark_partition_id().as("id"), $"val"),
+ data1d.map(i => Row(i, i)))
+
+ checkAnswer(
+ data1d.toDF("val").repartitionByRange(data1d.size, $"val".desc)
+ .select(spark_partition_id().as("id"), $"val"),
+ data1d.map(i => Row(i, data1d.size - 1 - i)))
+
+ // .repartitionByRange() assumes .asc by default if no explicit sort
order is specified
+ checkAnswer(
+ data2d.toDF("a", "b").repartitionByRange(data1d.size, $"a".desc,
$"b")
--- End diff --
`data1d.size`?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]