Skip to content

Commit 473552f

Browse files
scwfmarmbrus
authored andcommitted
[SPARK-7123] [SQL] support table.star in sqlcontext
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
1 parent 3ba5aaa commit 473552f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ class SqlParser extends AbstractSparkSQLParser with DataTypeParser {
365365

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

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
5151
Row("1", 1) :: Row("2", 1) :: Row("3", 1) :: Nil)
5252
}
5353

54+
test("support table.star") {
55+
checkAnswer(
56+
sql(
57+
"""
58+
|SELECT r.*
59+
|FROM testData l join testData2 r on (l.key = r.a)
60+
""".stripMargin),
61+
Row(1, 1) :: Row(1, 2) :: Row(2, 1) :: Row(2, 2) :: Row(3, 1) :: Row(3, 2) :: Nil)
62+
}
63+
5464
test("self join with alias in agg") {
5565
Seq(1,2,3)
5666
.map(i => (i, i.toString))

0 commit comments

Comments
 (0)