You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Tim Armstrong (JIRA)" <ji...@apache.org> on 2018/11/02 01:28:00 UTC

[jira] [Commented] (IMPALA-7083) AnalysisException for GROUP BY and ORDER BY expressions that are folded to constants from 2.9 onwards

    [ https://issues.apache.org/jira/browse/IMPALA-7083?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16672471#comment-16672471 ] 

Tim Armstrong commented on IMPALA-7083:
---------------------------------------

Another solution would be to call substituteOrdinalsAndAliases() on the expressions as the first step of the rewrite. We'd need to track globally that the expressions were the substituted versions and that they shouldn't be re-substituted.

> AnalysisException for GROUP BY and ORDER BY expressions that are folded to constants from 2.9 onwards
> -----------------------------------------------------------------------------------------------------
>
>                 Key: IMPALA-7083
>                 URL: https://issues.apache.org/jira/browse/IMPALA-7083
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Frontend
>    Affects Versions: Impala 2.9.0
>            Reporter: Eric Lin
>            Priority: Critical
>              Labels: regression
>
> To reproduce, please run below impala query:
> {code}
> 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);
> {code}
> It will fail with below error:
> {code}
> ERROR: AnalysisException: ORDER BY expression not produced by aggregation output (missing from GROUP BY clause?): (CASE WHEN TRUE THEN 1 ELSE a END)
> {code}
> However, if I replace column name "a" as a constant value, it works:
> {code}
> 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);
> {code}
> 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:
> {code}
> SELECT   ( 
>     CASE 
>        WHEN (1 =1) 
>        THEN 1
>        ELSE a
>     end) AS b
> FROM  test 
> GROUP BY 1 
> ORDER BY 1;
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org