Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-20841

Support table column aliases in FROM clause

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.0.0
    • 2.3.0
    • SQL
    • None

    Description

      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:

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

      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.

      Attachments

        There are no Sub-Tasks for this issue.

        Activity

          People

            maropu Takeshi Yamamuro
            joshrosen Josh Rosen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: