Skip to content
Snippets Groups Projects
Commit 8e94d272 authored by Takuya UESHIN's avatar Takuya UESHIN Committed by Patrick Wendell
Browse files

[SPARK-1778] [SQL] Add 'limit' transformation to SchemaRDD.

Add `limit` transformation to `SchemaRDD`.

Author: Takuya UESHIN <ueshin@happy-camper.st>

Closes #711 from ueshin/issues/SPARK-1778 and squashes the following commits:

33169df [Takuya UESHIN] Add 'limit' transformation to SchemaRDD.
parent 4d605532
No related branches found
No related tags found
No related merge requests found
......@@ -178,6 +178,15 @@ class SchemaRDD(
def orderBy(sortExprs: SortOrder*): 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.
*
......
......@@ -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)),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment