GitHub user HyukjinKwon opened a pull request:
https://github.com/apache/spark/pull/17566
[SPARK-19518][SQL] IGNORE NULLS in first / last in SQL
## What changes were proposed in this pull request?
This PR proposes to add `IGNORE NULLS` keyword in `first`/`last` in Spark's
parser likewise
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions057.htm. This
simply maps the keywords to existing `ignoreNullsExpr`.
**Before**
```scala
scala> sql("select first('a' IGNORE NULLS)").show()
```
```
org.apache.spark.sql.catalyst.parser.ParseException:
extraneous input 'NULLS' expecting {')', ','}(line 1, pos 24)
== SQL ==
select first('a' IGNORE NULLS)
------------------------^^^
at
org.apache.spark.sql.catalyst.parser.ParseException.withCommand(ParseDriver.scala:210)
at
org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parse(ParseDriver.scala:112)
at
org.apache.spark.sql.execution.SparkSqlParser.parse(SparkSqlParser.scala:46)
at
org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parsePlan(ParseDriver.scala:66)
at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:622)
... 48 elided
```
**After**
```scala
scala> sql("select first('a' IGNORE NULLS)").show()
```
```
+--------------+
|first(a, true)|
+--------------+
| a|
+--------------+
```
## How was this patch tested?
Unit tests in `ExpressionParserSuite`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/HyukjinKwon/spark SPARK-19518
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/17566.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #17566
----
commit eeaa6365433ed2344f69e8d6b6d09013d7c0175c
Author: hyukjinkwon <[email protected]>
Date: 2017-04-07T14:24:14Z
IGNORE NULLS in first / last expressions
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]