You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by pw...@apache.org on 2014/05/10 21:03:40 UTC
git commit: [SPARK-1778] [SQL] Add 'limit' transformation to
SchemaRDD.
Repository: spark
Updated Branches:
refs/heads/master 4d6055329 -> 8e94d2721
[SPARK-1778] [SQL] Add 'limit' transformation to SchemaRDD.
Add `limit` transformation to `SchemaRDD`.
Author: Takuya UESHIN <ue...@happy-camper.st>
Closes #711 from ueshin/issues/SPARK-1778 and squashes the following commits:
33169df [Takuya UESHIN] Add 'limit' transformation to SchemaRDD.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/8e94d272
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/8e94d272
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/8e94d272
Branch: refs/heads/master
Commit: 8e94d2721a9d3d36697e13f8cc6567ae8aeee78b
Parents: 4d60553
Author: Takuya UESHIN <ue...@happy-camper.st>
Authored: Sat May 10 12:03:27 2014 -0700
Committer: Patrick Wendell <pw...@gmail.com>
Committed: Sat May 10 12:03:27 2014 -0700
----------------------------------------------------------------------
.../src/main/scala/org/apache/spark/sql/SchemaRDD.scala | 9 +++++++++
.../src/test/scala/org/apache/spark/sql/DslQuerySuite.scala | 6 ++++++
2 files changed, 15 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/8e94d272/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala b/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala
index 34200be..2569815 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala
@@ -179,6 +179,15 @@ class SchemaRDD(
new SchemaRDD(sqlContext, Sort(sortExprs, logicalPlan))
/**
+ * Limits the results by the given expressions.
+ * {{{
+ * schemaRDD.limit(10)
+ * }}}
+ */
+ def limit(limitExpr: Expression): SchemaRDD =
+ new SchemaRDD(sqlContext, Limit(limitExpr, logicalPlan))
+
+ /**
* Performs a grouping followed by an aggregation.
*
* {{{
http://git-wip-us.apache.org/repos/asf/spark/blob/8e94d272/sql/core/src/test/scala/org/apache/spark/sql/DslQuerySuite.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DslQuerySuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DslQuerySuite.scala
index be0f4a4..92a707e 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/DslQuerySuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/DslQuerySuite.scala
@@ -71,6 +71,12 @@ class DslQuerySuite extends QueryTest {
Seq((3,1), (3,2), (2,1), (2,2), (1,1), (1,2)))
}
+ test("limit") {
+ checkAnswer(
+ testData.limit(10),
+ testData.take(10).toSeq)
+ }
+
test("average") {
checkAnswer(
testData2.groupBy()(Average('a)),