Skip to content

Commit

Permalink
[SPARK-7123] [SQL] support table.star in sqlcontext
Browse files Browse the repository at this point in the history
Run following sql get error
`SELECT r.*
FROM testData l join testData2 r on (l.key = r.a)`

Author: scwf <[email protected]>

Closes apache#5690 from scwf/tablestar and squashes the following commits:

3b2e2b6 [scwf] support table.star
  • Loading branch information
scwf authored and marmbrus committed May 1, 2015
1 parent 3ba5aaa commit 473552f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ class SqlParser extends AbstractSparkSQLParser with DataTypeParser {

protected lazy val baseExpression: Parser[Expression] =
( "*" ^^^ UnresolvedStar(None)
| ident <~ "." ~ "*" ^^ { case tableName => UnresolvedStar(Option(tableName)) }
| primary
)

Expand Down
10 changes: 10 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 @@ -51,6 +51,16 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
Row("1", 1) :: Row("2", 1) :: Row("3", 1) :: Nil)
}

test("support table.star") {
checkAnswer(
sql(
"""
|SELECT r.*
|FROM testData l join testData2 r on (l.key = r.a)
""".stripMargin),
Row(1, 1) :: Row(1, 2) :: Row(2, 1) :: Row(2, 2) :: Row(3, 1) :: Row(3, 2) :: Nil)
}

test("self join with alias in agg") {
Seq(1,2,3)
.map(i => (i, i.toString))
Expand Down

0 comments on commit 473552f

Please sign in to comment.