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

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Frontend
    • Labels:
      None
    • Epic Color:
      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

            • Assignee:
              superdupershant Shant Hovsepian
              Reporter:
              grahn Greg Rahn
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: