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

Identifier in HAVING expr should fall back from SELECT item aliases to columns in FROM table refs

    Details

      Description

      Both Postgresql and Oracle accept the query below

      Query: select COUNT(1) AS int_col FROM alltypestiny HAVING SUM(int_col) > 1
      ERROR: AnalysisException: null
      CAUSED BY: IllegalStateException: Failed analysis after expr substitution.
      CAUSED BY: AnalysisException: aggregate function must not contain aggregate parameters: sum(count(1))
      

      It seems Impala uses the SELECT item alias then immediately aborts when that is not valid whereas Postgresql and Oracle fall back to the table column.

      Postgresql

      functional=# SELECT COUNT(1) AS int_col FROM alltypestiny HAVING SUM(int_col) > 1;
       int_col 
      ---------
             8
      (1 row)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                caseyc casey
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: