GitHub user hvanhovell opened a pull request:
https://github.com/apache/spark/pull/17245
[SPARK-19850][SQL] Allow the use of aliases in SQL function calls
## What changes were proposed in this pull request?
We currently cannot use aliases in SQL function calls. This is inconvenient
when you try to create a struct. This SQL query for example `select struct(1,
2) st`, will create a struct with column names `col1` and `col2`. This is even
more problematic when we want to append a field to an existing struct. For
example if we want to a field to struct `st` we would issue the following SQL
query `select struct(st.*, 1) as st from src`, the result will be struct `st`
with an a column with a non descriptive name `col3` (if `st` itself has 2
fields).
This PR proposes to change this by allowing the use of aliased expression
in function parameters. For example `select struct(1 as a, 2 as b) st`, will
create a struct with columns `a` & `b`.
## How was this patch tested?
Added a test to `ExpressionParserSuite` and added a test file for
`SQLQueryTestSuite`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/hvanhovell/spark SPARK-19850
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/17245.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 #17245
----
commit 2172c08cb593e148a5223655ba14f2a708e5c3db
Author: Herman van Hovell <[email protected]>
Date: 2017-03-10T16:42:25Z
Allow the use of aliases in SQL function calls.
----
---
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]