diff options
author | Reynold Xin <rxin@databricks.com> | 2015-02-03 22:15:35 -0800 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2015-02-03 22:15:35 -0800 |
commit | 40c4cb2fe79ceac0d656be7b72cb2ee8d7db7258 (patch) | |
tree | 581df79783cd7b5bef1c51b0156f85265689dae2 /sql/catalyst/src | |
parent | eb15631854f8e8e7bcd1b3331f18d6ee81dd6d5c (diff) | |
download | spark-40c4cb2fe79ceac0d656be7b72cb2ee8d7db7258.tar.gz spark-40c4cb2fe79ceac0d656be7b72cb2ee8d7db7258.tar.bz2 spark-40c4cb2fe79ceac0d656be7b72cb2ee8d7db7258.zip |
[SPARK-5579][SQL][DataFrame] Support for project/filter using SQL expressions
```scala
df.selectExpr("abs(colA)", "colB")
df.filter("age > 21")
```
Author: Reynold Xin <rxin@databricks.com>
Closes #4348 from rxin/SPARK-5579 and squashes the following commits:
2baeef2 [Reynold Xin] Fix Python.
b416372 [Reynold Xin] [SPARK-5579][SQL][DataFrame] Support for project/filter using SQL expressions.
Diffstat (limited to 'sql/catalyst/src')
-rwxr-xr-x | sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/SqlParser.scala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/SqlParser.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/SqlParser.scala index 5c006e9d4c..a9bd079c70 100755 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/SqlParser.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/SqlParser.scala @@ -36,6 +36,16 @@ import org.apache.spark.sql.types._ * for a SQL like language should checkout the HiveQL support in the sql/hive sub-project. */ class SqlParser extends AbstractSparkSQLParser { + + def parseExpression(input: String): Expression = { + // Initialize the Keywords. + lexical.initialize(reservedWords) + phrase(expression)(new lexical.Scanner(input)) match { + case Success(plan, _) => plan + case failureOrError => sys.error(failureOrError.toString) + } + } + // Keyword is a convention with AbstractSparkSQLParser, which will scan all of the `Keyword` // properties via reflection the class in runtime for constructing the SqlLexical object protected val ABS = Keyword("ABS") |