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

Impala query failed with error AnalysisException from 2.9 onwards

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: Impala 2.9.0
    • Fix Version/s: None
    • Component/s: Frontend
    • Labels:
      None
    • Epic Color:
      ghx-label-7

      Description

      To reproduce, please run below impala query:

      DROP TABLE IF EXISTS test;
      CREATE TABLE test (a int);
      
      SELECT   ( 
          CASE 
             WHEN (1 =1) 
             THEN 1
             ELSE a
          end) AS b
      FROM  test 
      GROUP BY 1 
      ORDER BY ( 
          CASE 
             WHEN (1 =1) 
             THEN 1
             ELSE a
          end);
      

      It will fail with below error:

      ERROR: AnalysisException: ORDER BY expression not produced by aggregation output (missing from GROUP BY clause?): (CASE WHEN TRUE THEN 1 ELSE a END)
      

      However, if I replace column name "a" as a constant value, it works:

      SELECT   ( 
          CASE 
             WHEN (1 =1) 
             THEN 1
             ELSE 2
          end) AS b
      FROM  test 
      GROUP BY 1 
      ORDER BY ( 
          CASE 
             WHEN (1 =1) 
             THEN 1
             ELSE 2
          end);
      

      This issue is identified in CDH5.12.x (Impala 2.9), and no issues in 5.11.x (Impala 2.8).

      We know that it can be worked around by re-write as below:

      SELECT   ( 
          CASE 
             WHEN (1 =1) 
             THEN 1
             ELSE a
          end) AS b
      FROM  test 
      GROUP BY 1 
      ORDER BY 1;
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ericlin Eric Lin
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: