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

Behavior of GROUP BY, HAVING, ORDER BY with column aliases should be more standard conforming

    Details

    • Epic Color:
      ghx-label-3

      Description

      Allow Impala to accept "column alias" and "Column name" indistinctly in the group by clause (also if Column is made by a function).
      We are confident that this can contribute to the growing of this Engine.

      This is a sample of a statement that we would like to execute with success:

      with w_test as
        (select '1' as one,
                2 as two,
                '3' as three)
      select one as one,
             substring(cast(two as string), 1, 1) as two,
             three as three,
             count(1) as cnt
      from w_test
      group by one,
               substring(cast(two as string), 1, 1),
               three
      
      ERROR: AnalysisException: select list expression not produced by aggregation output (missing from GROUP BY clause?): substring(CAST(two AS STRING), 1, 1)
      

      It works writing the statements as:

      workaround.1:

      with w_test as
        (select '1' as one,
                2 as two,
                '3' as three)
      select one,
             substring(cast(two as string), 1, 1),
             three,
             count(1)
      from w_test
      group by one,
               substring(cast(two as string), 1, 1),
               three
      

      workaround.2:

      with w_test as
        (select '1' as one,
                2 as two,
                '3' as three)
      select one as one,
             substring(cast(two as string), 1, 1) as two,
             three as three,
             count(1) as cnt
      from w_test
      group by 1,
               2,
               3
      

      workaround 3:

      with w_test as
        (select '1' as one,
                2 as two,
                '3' as three)
      select one as t_one,
             substring(cast(two as string), 1, 1) as t_two,
             three as t_three,
             count(1) as cnt
      from w_test
      group by t_one,
               t_two,
               t_three
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                boroknagyz Zoltán Borók-Nagy
                Reporter:
                adrenas Adriano
              • Votes:
                0 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: