Skip to content

Commit 1cfbfe6

Browse files
committed
refomat some files
1 parent ea78f33 commit 1cfbfe6

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/SqlParser.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
*
22
* Licensed to the Apache Software Foundation (ASF) under one or more
33
* contributor license agreements. See the NOTICE file distributed with
44
* this work for additional information regarding copyright ownership.
@@ -121,6 +121,7 @@ class SqlParser extends StandardTokenParsers with PackratParsers {
121121
protected val INTERSECT = Keyword("INTERSECT")
122122
protected val EXCEPT = Keyword("EXCEPT")
123123

124+
124125
// Use reflection to find the reserved words defined in this class.
125126
protected val reservedWords =
126127
this.getClass
@@ -140,11 +141,8 @@ class SqlParser extends StandardTokenParsers with PackratParsers {
140141
protected lazy val query: Parser[LogicalPlan] = (
141142
select * (
142143
UNION ~ ALL ^^^ { (q1: LogicalPlan, q2: LogicalPlan) => Union(q1, q2) } |
143-
<<<<<<< HEAD
144144
INTERSECT ^^^ { (q1: LogicalPlan, q2: LogicalPlan) => Intersect(q1, q2)} |
145-
=======
146145
EXCEPT ^^^ { (q1: LogicalPlan, q2: LogicalPlan) => Except(q1, q2)} |
147-
>>>>>>> upstream/master
148146
UNION ~ opt(DISTINCT) ^^^ { (q1: LogicalPlan, q2: LogicalPlan) => Distinct(Union(q1, q2)) }
149147
)
150148
| insert | cache

sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ private[sql] abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
272272
case logical.Limit(IntegerLiteral(limit), child) =>
273273
execution.Limit(limit, planLater(child))(sqlContext) :: Nil
274274
case Unions(unionChildren) =>
275-
execution.Union(unionChildren.map(planLater))(sqlContext) :: Nil
276-
case logical.Intersect(left,right) =>
277-
execution.Intersect(planLater(left),planLater(right)) :: Nil
275+
execution.Union(unionChildren.map(planLater))(sqlContext) :: Nil
278276
case logical.Except(left,right) =>
279277
execution.Except(planLater(left),planLater(right)) :: Nil
278+
case logical.Intersect(left,right) =>
279+
execution.Intersect(planLater(left),planLater(right)) :: Nil
280280
case logical.Generate(generator, join, outer, _, child) =>
281281
execution.Generate(generator, join = join, outer = outer, planLater(child)) :: Nil
282282
case logical.NoRelation =>

sql/core/src/main/scala/org/apache/spark/sql/execution/basicOperators.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,28 +208,28 @@ case class ExistingRdd(output: Seq[Attribute], rdd: RDD[Row]) extends LeafNode {
208208

209209
/**
210210
* :: DeveloperApi ::
211-
*Returns the rows in left that also appear in right using the built in spark
212-
*intersection function.
211+
* Returns a table with the elements from left that are not in right using
212+
* the built-in spark subtract function.
213213
*/
214214
@DeveloperApi
215-
case class Intersect(left: SparkPlan, right: SparkPlan) extends BinaryNode {
216-
override def output = children.head.output
215+
case class Except(left: SparkPlan, right: SparkPlan) extends BinaryNode {
216+
override def output = left.output
217217

218218
override def execute() = {
219-
left.execute().map(_.copy()).intersection(right.execute().map(_.copy()))
219+
left.execute().map(_.copy()).subtract(right.execute().map(_.copy()))
220220
}
221221
}
222222

223223
/**
224224
* :: DeveloperApi ::
225-
* Returns a table with the elements from left that are not in right using
226-
* the built-in spark subtract function.
225+
*Returns the rows in left that also appear in right using the built in spark
226+
*intersection function.
227227
*/
228228
@DeveloperApi
229-
case class Except(left: SparkPlan, right: SparkPlan) extends BinaryNode {
230-
override def output = left.output
229+
case class Intersect(left: SparkPlan, right: SparkPlan) extends BinaryNode {
230+
override def output = children.head.output
231231

232232
override def execute() = {
233-
left.execute().map(_.copy()).subtract(right.execute().map(_.copy()))
233+
left.execute().map(_.copy()).intersection(right.execute().map(_.copy()))
234234
}
235235
}

sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -371,28 +371,28 @@ class SQLQuerySuite extends QueryTest {
371371
(3, null)))
372372
}
373373

374-
test("INTERSECT") {
374+
test("EXCEPT") {
375375
checkAnswer(
376-
sql("SELECT * FROM lowerCaseData INTERSECT SELECT * FROM lowerCaseData "),
376+
sql("SELECT * FROM lowerCaseData EXCEPT SELECT * FROM upperCaseData "),
377377
(1, "a") ::
378378
(2, "b") ::
379379
(3, "c") ::
380380
(4, "d") :: Nil)
381381
checkAnswer(
382-
sql("SELECT * FROM lowerCaseData INTERSECT SELECT * FROM upperCaseData "), Nil)
383-
}
382+
sql("SELECT * FROM lowerCaseData EXCEPT SELECT * FROM lowerCaseData "), Nil)
383+
checkAnswer(
384+
sql("SELECT * FROM upperCaseData EXCEPT SELECT * FROM upperCaseData "), Nil)
385+
}
384386

385-
test("EXCEPT") {
387+
test("INTERSECT") {
386388
checkAnswer(
387-
sql("SELECT * FROM lowerCaseData EXCEPT SELECT * FROM upperCaseData "),
389+
sql("SELECT * FROM lowerCaseData INTERSECT SELECT * FROM lowerCaseData "),
388390
(1, "a") ::
389391
(2, "b") ::
390392
(3, "c") ::
391393
(4, "d") :: Nil)
392394
checkAnswer(
393-
sql("SELECT * FROM lowerCaseData EXCEPT SELECT * FROM lowerCaseData "), Nil)
394-
checkAnswer(
395-
sql("SELECT * FROM upperCaseData EXCEPT SELECT * FROM upperCaseData "), Nil)
395+
sql("SELECT * FROM lowerCaseData INTERSECT SELECT * FROM upperCaseData "), Nil)
396396
}
397397

398398
test("SET commands semantics using sql()") {

0 commit comments

Comments
 (0)