Skip to content
Snippets Groups Projects
Commit 1b3ce61c authored by Cheng Lian's avatar Cheng Lian Committed by Michael Armbrust
Browse files

[SPARK-3906][SQL] Adds multiple join support for SQLContext

Author: Cheng Lian <lian.cs.zju@gmail.com>

Closes #2767 from liancheng/multi-join and squashes the following commits:

9dc0d18 [Cheng Lian] Adds multiple join support for SQLContext
parent eadc4c59
No related branches found
No related tags found
No related merge requests found
......@@ -181,9 +181,11 @@ class SqlParser extends AbstractSparkSQLParser {
)
protected lazy val joinedRelation: Parser[LogicalPlan] =
relationFactor ~ joinType.? ~ (JOIN ~> relationFactor) ~ joinConditions.? ^^ {
case r1 ~ jt ~ r2 ~ cond =>
Join(r1, r2, joinType = jt.getOrElse(Inner), cond)
relationFactor ~ rep1(joinType.? ~ (JOIN ~> relationFactor) ~ joinConditions.?) ^^ {
case r1 ~ joins =>
joins.foldLeft(r1) { case (lhs, jt ~ rhs ~ cond) =>
Join(lhs, rhs, joinType = jt.getOrElse(Inner), cond)
}
}
protected lazy val joinConditions: Parser[Expression] =
......
......@@ -720,4 +720,15 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
checkAggregation("SELECT key + 2, COUNT(*) FROM testData GROUP BY key + 1")
checkAggregation("SELECT key + 1 + 1, COUNT(*) FROM testData GROUP BY key + 1", false)
}
test("Multiple join") {
checkAnswer(
sql(
"""SELECT a.key, b.key, c.key
|FROM testData a
|JOIN testData b ON a.key = b.key
|JOIN testData c ON a.key = c.key
""".stripMargin),
(1 to 100).map(i => Seq(i, i, i)))
}
}
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