Josh Rosen created SPARK-20841:
----------------------------------

             Summary: Support table column aliases in FROM clause
                 Key: SPARK-20841
                 URL: https://issues.apache.org/jira/browse/SPARK-20841
             Project: Spark
          Issue Type: Improvement
          Components: SQL
    Affects Versions: 2.0.0
            Reporter: Josh Rosen
            Priority: Minor


Some SQL dialects support a relatively obscure "table column aliases" feature 
where you can rename columns when aliasing a relation in a {{FROM}} clause. For 
example:

{code}
SELECT * FROM onecolumn AS a(x) JOIN onecolumn AS b(y) ON a.x = b.y
{code}

Spark does not currently support this. I would like to add support for this in 
order to allow me to run a corpus of existing queries which depend on this 
syntax.

There's a good writeup on this at 
http://modern-sql.com/feature/table-column-aliases, which has additional 
examples and describes other databases' degrees of support for this feature.

One tricky thing to figure out will be whether FROM clause column aliases take 
precedence over aliases in the SELECT clause. When adding support for this, we 
should make sure to add sufficient testing of several corner-cases, including:

* Aliasing in both the SELECT and FROM clause
* Aliasing columns in the FROM clause both with and without an explicit AS.
* Aliasing the wrong number of columns in the FROM clause, both greater and 
fewer columns than were selected in the SELECT clause.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to