aboutsummaryrefslogtreecommitdiff
path: root/sql/core/src/test
diff options
context:
space:
mode:
authorReynold Xin <rxin@databricks.com>2015-04-28 00:39:08 -0700
committerReynold Xin <rxin@databricks.com>2015-04-28 00:39:08 -0700
commitd94cd1a733d5715792e6c4eac87f0d5c81aebbe2 (patch)
tree79757d52491eaf74b527a4b280d4762ab21dae20 /sql/core/src/test
parentbf35edd9d4b8b11df9f47b6ff43831bc95f06322 (diff)
downloadspark-d94cd1a733d5715792e6c4eac87f0d5c81aebbe2.tar.gz
spark-d94cd1a733d5715792e6c4eac87f0d5c81aebbe2.tar.bz2
spark-d94cd1a733d5715792e6c4eac87f0d5c81aebbe2.zip
[SPARK-7135][SQL] DataFrame expression for monotonically increasing IDs.
Author: Reynold Xin <rxin@databricks.com> Closes #5709 from rxin/inc-id and squashes the following commits: 7853611 [Reynold Xin] private sql. a9fda0d [Reynold Xin] Missed a few numbers. 343d896 [Reynold Xin] Self review feedback. a7136cb [Reynold Xin] [SPARK-7135][SQL] DataFrame expression for monotonically increasing IDs.
Diffstat (limited to 'sql/core/src/test')
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala11
1 files changed, 11 insertions, 0 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala
index 680b5c6369..2ba5fc21ff 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala
@@ -309,6 +309,17 @@ class ColumnExpressionSuite extends QueryTest {
)
}
+ test("monotonicallyIncreasingId") {
+ // Make sure we have 2 partitions, each with 2 records.
+ val df = TestSQLContext.sparkContext.parallelize(1 to 2, 2).mapPartitions { iter =>
+ Iterator(Tuple1(1), Tuple1(2))
+ }.toDF("a")
+ checkAnswer(
+ df.select(monotonicallyIncreasingId()),
+ Row(0L) :: Row(1L) :: Row((1L << 33) + 0L) :: Row((1L << 33) + 1L) :: Nil
+ )
+ }
+
test("sparkPartitionId") {
val df = TestSQLContext.sparkContext.parallelize(1 to 1, 1).map(i => (i, i)).toDF("a", "b")
checkAnswer(