Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
More idiomatic naming of DSL functions.
* subquery => as
* for join condition => on, i.e., `r.join(s, condition = 'a == 'b)` =>`r.join(s, on = 'a == 'b)`
  • Loading branch information
marmbrus committed Apr 4, 2014
commit 208bf5eacf38e57657d01f7de0f680294addafa4
10 changes: 5 additions & 5 deletions sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class SchemaRDD(
def join(
otherPlan: SchemaRDD,
joinType: JoinType = Inner,
condition: Option[Expression] = None): SchemaRDD =
new SchemaRDD(sqlContext, Join(logicalPlan, otherPlan.logicalPlan, joinType, condition))
on: Option[Expression] = None): SchemaRDD =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to update the scaladoc above

new SchemaRDD(sqlContext, Join(logicalPlan, otherPlan.logicalPlan, joinType, on))

/**
* Sorts the results by the given expressions.
Expand Down Expand Up @@ -195,14 +195,14 @@ class SchemaRDD(
* with the same name, for example, when peforming self-joins.
*
* {{{
* val x = schemaRDD.where('a === 1).subquery('x)
* val y = schemaRDD.where('a === 2).subquery('y)
* val x = schemaRDD.where('a === 1).as('x)
* val y = schemaRDD.where('a === 2).as('y)
* x.join(y).where("x.a".attr === "y.a".attr),
* }}}
*
* @group Query
*/
def subquery(alias: Symbol) =
def as(alias: Symbol) =
new SchemaRDD(sqlContext, Subquery(alias.name, logicalPlan))

/**
Expand Down
16 changes: 8 additions & 8 deletions sql/core/src/test/scala/org/apache/spark/sql/DslQuerySuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class DslQuerySuite extends QueryTest {
}

test("inner join, where, multiple matches") {
val x = testData2.where('a === 1).subquery('x)
val y = testData2.where('a === 1).subquery('y)
val x = testData2.where('a === 1).as('x)
val y = testData2.where('a === 1).as('y)
checkAnswer(
x.join(y).where("x.a".attr === "y.a".attr),
(1,1,1,1) ::
Expand All @@ -131,17 +131,17 @@ class DslQuerySuite extends QueryTest {
}

test("inner join, no matches") {
val x = testData2.where('a === 1).subquery('x)
val y = testData2.where('a === 2).subquery('y)
val x = testData2.where('a === 1).as('x)
val y = testData2.where('a === 2).as('y)
checkAnswer(
x.join(y).where("x.a".attr === "y.a".attr),
Nil)
}

test("big inner join, 4 matches per row") {
val bigData = testData.unionAll(testData).unionAll(testData).unionAll(testData)
val bigDataX = bigData.subquery('x)
val bigDataY = bigData.subquery('y)
val bigDataX = bigData.as('x)
val bigDataY = bigData.as('y)

checkAnswer(
bigDataX.join(bigDataY).where("x.key".attr === "y.key".attr),
Expand Down Expand Up @@ -181,8 +181,8 @@ class DslQuerySuite extends QueryTest {
}

test("full outer join") {
val left = upperCaseData.where('N <= 4).subquery('left)
val right = upperCaseData.where('N >= 3).subquery('right)
val left = upperCaseData.where('N <= 4).as('left)
val right = upperCaseData.where('N >= 3).as('right)

checkAnswer(
left.join(right, FullOuter, Some("left.N".attr === "right.N".attr)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class ParquetQuerySuite extends FunSuite with BeforeAndAfterAll {
}

test("self-join parquet files") {
val x = ParquetTestData.testData.subquery('x)
val y = ParquetTestData.testData.subquery('y)
val x = ParquetTestData.testData.as('x)
val y = ParquetTestData.testData.as('y)
val query = x.join(y).where("x.myint".attr === "y.myint".attr)

// Check to make sure that the attributes from either side of the join have unique expression
Expand Down