Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5126

Implicit column alias for single-column UNNEST should work with any single-column UNNEST’s input

    XMLWordPrintableJSON

Details

    Description

      Implicit column alias works only in case with scalar array, but it should work with any single-column UNNEST’s input

      There are the following lines in PostgresSQL documentation( https://www.postgresql.org/docs/current/queries-table-expressions.html) regarding table functions like “UNNEST”:

      If column aliases are not supplied, then for a function returning a base data type, the column name is also the same as the function name.

      From BigQuery documentation (https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#implicit_aliases):

      For input ARRAYs of most element types, the output of UNNEST generally has one column. This single column has an optional alias, which you can use to refer to the column elsewhere in the query

      Examples:

      psql => SELECT * FROM UNNEST(array(select 1 as x)) y;
       y
      ---
       1
      (1 row)
      
      CREATE TABLE testtable (
          strings text[]
      );
      INSERT INTO testtable VALUES(ARRAY['1', '2', '3'])
      SELECT array(SELECT 'toast' || x FROM unnest(tt.strings) x) FROM testtable as tt;
      
               array
      ------------------------
       {toast1,toast2,toast3}
      (1 row)
      

      Attachments

        Issue Links

          Activity

            People

              dmsysolyatin Dmitry Sysolyatin
              dmsysolyatin Dmitry Sysolyatin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h
                  2h