Skip to content
Snippets Groups Projects
Commit 10b59ba2 authored by Takuya UESHIN's avatar Takuya UESHIN Committed by Michael Armbrust
Browse files

[SPARK-2428][SQL] Add except and intersect methods to SchemaRDD.

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

Closes #1355 from ueshin/issues/SPARK-2428 and squashes the following commits:

b6fa264 [Takuya UESHIN] Add except and intersect methods to SchemaRDD.
parent f5abd271
No related branches found
No related tags found
No related merge requests found
......@@ -256,6 +256,26 @@ class SchemaRDD(
def unionAll(otherPlan: SchemaRDD) =
new SchemaRDD(sqlContext, Union(logicalPlan, otherPlan.logicalPlan))
/**
* Performs a relational except on two SchemaRDDs
*
* @param otherPlan the [[SchemaRDD]] that should be excepted from this one.
*
* @group Query
*/
def except(otherPlan: SchemaRDD): SchemaRDD =
new SchemaRDD(sqlContext, Except(logicalPlan, otherPlan.logicalPlan))
/**
* Performs a relational intersect on two SchemaRDDs
*
* @param otherPlan the [[SchemaRDD]] that should be intersected with this one.
*
* @group Query
*/
def intersect(otherPlan: SchemaRDD): SchemaRDD =
new SchemaRDD(sqlContext, Intersect(logicalPlan, otherPlan.logicalPlan))
/**
* Filters tuples using a function over the value of the specified column.
*
......
......@@ -168,4 +168,25 @@ class DslQuerySuite extends QueryTest {
test("zero count") {
assert(emptyTableData.count() === 0)
}
test("except") {
checkAnswer(
lowerCaseData.except(upperCaseData),
(1, "a") ::
(2, "b") ::
(3, "c") ::
(4, "d") :: Nil)
checkAnswer(lowerCaseData.except(lowerCaseData), Nil)
checkAnswer(upperCaseData.except(upperCaseData), Nil)
}
test("intersect") {
checkAnswer(
lowerCaseData.intersect(lowerCaseData),
(1, "a") ::
(2, "b") ::
(3, "c") ::
(4, "d") :: Nil)
checkAnswer(lowerCaseData.intersect(upperCaseData), Nil)
}
}
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