Skip to content

Commit

Permalink
[SPARK-5910][SQL] Support for as in selectExpr
Browse files Browse the repository at this point in the history
Author: Michael Armbrust <[email protected]>

Closes apache#4736 from marmbrus/asExprs and squashes the following commits:

5ba97e4 [Michael Armbrust] [SPARK-5910][SQL] Support for as in selectExpr
  • Loading branch information
marmbrus committed Feb 24, 2015
1 parent 8403331 commit 0a59e45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SqlParser extends AbstractSparkSQLParser {
def parseExpression(input: String): Expression = {
// Initialize the Keywords.
lexical.initialize(reservedWords)
phrase(expression)(new lexical.Scanner(input)) match {
phrase(projection)(new lexical.Scanner(input)) match {
case Success(plan, _) => plan
case failureOrError => sys.error(failureOrError.toString)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ class DataFrameSuite extends QueryTest {
testData.collect().map(row => Row(math.abs(row.getInt(0)), row.getString(1))).toSeq)
}

test("selectExpr with alias") {
checkAnswer(
testData.selectExpr("key as k").select("k"),
testData.select("key").collect().toSeq)
}

test("filterExpr") {
checkAnswer(
testData.filter("key > 90"),
Expand Down

0 comments on commit 0a59e45

Please sign in to comment.