Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
aa06072
Reformat the code sytle
YanjieGao Jun 20, 2014
4eb43ec
Update basicOperators.scala
YanjieGao Jun 20, 2014
68815b2
Reformat the code style
YanjieGao Jun 20, 2014
dd32980
update1
YanjieGao Jun 22, 2014
2b98962
Update SqlParser.scala
YanjieGao Jun 22, 2014
8945835
object SkewJoin extends Strategy
YanjieGao Jun 22, 2014
cf5b9d0
Update basicOperators.scala
YanjieGao Jun 23, 2014
7a98c37
Update basicOperators.scala
YanjieGao Jun 23, 2014
3305e40
SqlParser
YanjieGao Jun 23, 2014
1fe96c0
HiveQl.scala update
YanjieGao Jun 23, 2014
a8a1948
SparkStrategies
YanjieGao Jun 23, 2014
0808921
SQLQuerySuite
YanjieGao Jun 23, 2014
2d4bfbd
Update SQLQuerySuite.scala
YanjieGao Jun 23, 2014
4bdd520
Update SqlParser.scala
YanjieGao Jun 23, 2014
4bf80b1
update subtract to except
YanjieGao Jun 23, 2014
aab3785
Update SQLQuerySuite.scala
YanjieGao Jun 23, 2014
052346d
Subtract is conflict with Subtract(e1,e2)
YanjieGao Jun 23, 2014
7859e56
Update SparkStrategies.scala
YanjieGao Jun 23, 2014
a36eb0a
Update basicOperators.scala
YanjieGao Jun 23, 2014
3fe7746
Update SQLQuerySuite.scala
YanjieGao Jun 23, 2014
670a1bb
Update HiveQl.scala
YanjieGao Jun 23, 2014
7f3d613
update .map(_.copy())
YanjieGao Jun 23, 2014
7ea9b91
remove annotation
YanjieGao Jun 27, 2014
f1ea3f3
remove comment
YanjieGao Jun 27, 2014
cf232eb
update 1comment 2space3 left.out
YanjieGao Jun 27, 2014
32a80ab
remove except in HiveQl
YanjieGao Jun 27, 2014
ee066b3
Update basicOperators.scala
YanjieGao Jun 27, 2014
5c8a224
update the line less than 100c
YanjieGao Jun 27, 2014
a7193d8
[SPARK-2234][SQL]Spark SQL basicOperators add Except operator #1151
YanjieGao Jul 1, 2014
7680742
Update SqlParser.scala
YanjieGao Jul 1, 2014
424c507
Update joins.scala
YanjieGao Jul 1, 2014
d6a4604
Update joins.scala
YanjieGao Jul 1, 2014
9847dcf
update SqlParser on masterbranch
YanjieGao Jul 1, 2014
8dd063f
Update logical/basicOperators on master branch
YanjieGao Jul 1, 2014
26f833f
update SparkStrategies.scala on master branch
YanjieGao Jul 1, 2014
3bf7def
update SqlParser on master branch
YanjieGao Jul 1, 2014
a639935
Update SparkStrategies.scala
YanjieGao Jul 1, 2014
a28dece
Update logical/basicOperators on master branch
YanjieGao Jul 1, 2014
7f916b5
update execution/basicOperators on master branch
YanjieGao Jul 1, 2014
0e72233
update SQLQuerySuite on master branch
YanjieGao Jul 1, 2014
60f5ddd
update less than 100c
YanjieGao Jul 1, 2014
a0d4e73
delete skew join
YanjieGao Jul 2, 2014
dd9ba5e
Update joins.scala
YanjieGao Jul 2, 2014
8e6bb00
delete conflict except
YanjieGao Jul 2, 2014
fa68a98
Update joins.scala
YanjieGao Jul 2, 2014
4dc8166
resolve conflict
YanjieGao Jul 2, 2014
b01beb8
resolve conflict sparkstrategies and basicOperators
YanjieGao Jul 2, 2014
7e7c83f
delete conflict except
YanjieGao Jul 2, 2014
7e0ec29
delete multi test
YanjieGao Jul 2, 2014
b4c3869
change SparkStrategies Sparkcontext to SqlContext
YanjieGao Jul 2, 2014
b4b5867
Merge remote branch 'upstream/master' into patch-6
Jul 3, 2014
09c7413
pr 1151 SqlParser add cache ,basic Operator rename Except and modify …
YanjieGao Jul 3, 2014
9940d19
make comment less than 100c
YanjieGao Jul 3, 2014
fdb5227
Merge remote branch 'upstream/master' into patch-6
YanjieGao Jul 4, 2014
2ff7d73
resolve the identation in SqlParser and SparkStrategies
YanjieGao Jul 4, 2014
f19f899
add a new blank line in basicoperators.scala
YanjieGao Jul 4, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class SqlParser extends StandardTokenParsers with PackratParsers {
protected val UNCACHE = Keyword("UNCACHE")
protected val UNION = Keyword("UNION")
protected val WHERE = Keyword("WHERE")
protected val EXCEPT = Keyword("EXCEPT")


// Use reflection to find the reserved words defined in this class.
protected val reservedWords =
Expand All @@ -138,6 +140,7 @@ class SqlParser extends StandardTokenParsers with PackratParsers {
protected lazy val query: Parser[LogicalPlan] = (
select * (
UNION ~ ALL ^^^ { (q1: LogicalPlan, q2: LogicalPlan) => Union(q1, q2) } |
EXCEPT ^^^ { (q1: LogicalPlan, q2: LogicalPlan) => Except(q1, q2)} |
UNION ~ opt(DISTINCT) ^^^ { (q1: LogicalPlan, q2: LogicalPlan) => Distinct(Union(q1, q2)) }
)
| insert | cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ case class Join(
}
}

case class Except(left: LogicalPlan, right: LogicalPlan) extends BinaryNode {
def output = left.output

def references = Set.empty
}

case class InsertIntoTable(
table: LogicalPlan,
partition: Map[String, Option[String]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
execution.Limit(limit, planLater(child))(sqlContext) :: Nil
case Unions(unionChildren) =>
execution.Union(unionChildren.map(planLater))(sqlContext) :: Nil
case logical.Except(left,right) =>
execution.Except(planLater(left),planLater(right)) :: Nil
case logical.Generate(generator, join, outer, _, child) =>
execution.Generate(generator, join = join, outer = outer, planLater(child)) :: Nil
case logical.NoRelation =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,18 @@ object ExistingRdd {
case class ExistingRdd(output: Seq[Attribute], rdd: RDD[Row]) extends LeafNode {
override def execute() = rdd
}

/**
* :: DeveloperApi ::
* Returns a table with the elements from left that are not in right using
* the built-in spark subtract function.
*/
@DeveloperApi
case class Except(left: SparkPlan, right: SparkPlan) extends BinaryNode {
override def output = left.output

override def execute() = {
left.execute().map(_.copy()).subtract(right.execute().map(_.copy()))
}
}

14 changes: 14 additions & 0 deletions sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,20 @@ class SQLQuerySuite extends QueryTest {
(3, null)))
}

test("EXCEPT") {

checkAnswer(
sql("SELECT * FROM lowerCaseData EXCEPT SELECT * FROM upperCaseData "),
(1, "a") ::
(2, "b") ::
(3, "c") ::
(4, "d") :: Nil)
checkAnswer(
sql("SELECT * FROM lowerCaseData EXCEPT SELECT * FROM lowerCaseData "), Nil)
checkAnswer(
sql("SELECT * FROM upperCaseData EXCEPT SELECT * FROM upperCaseData "), Nil)
}

test("SET commands semantics using sql()") {
TestSQLContext.settings.synchronized {
clear()
Expand Down