Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-9018

ORDER BY using an expression + column alias fails with "Could not resolve column/field"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • None
    • None
    • Frontend
    • None
    • ghx-label-12

    Description

      Test case:

      select version();
      
      +-----------------------------------------------------------------------------------------+
      | version()                                                                               |
      +-----------------------------------------------------------------------------------------+
      | impalad version 3.4.0-SNAPSHOT RELEASE (build f047e967d099119717d1d3bbb7a235554707513f) |
      | Built on Mon Oct  7 10:07:27 UTC 2019                                                   |
      +-----------------------------------------------------------------------------------------+
      
      -- works
      with t as (select a from (values(1 as a),(2),(3)) t)
      select
        a, 
        a + 10 as alias_of_a
      from t
      order by abs(a);
      
      +---+------------+
      | a | alias_of_a |
      +---+------------+
      | 1 | 11         |
      | 2 | 12         |
      | 3 | 13         |
      +---+------------+
      
      -- fails with 
      -- AnalysisException: Could not resolve column/field reference: 'alias_of_a'
      with t as (select a from (values(1 as a),(2),(3)) t)
      select
        a, 
        a + 10 as alias_of_a
      from t
      order by abs(alias_of_a);
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            grahn Greg Rahn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: