[ 
https://issues.apache.org/jira/browse/IMPALA-11612?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

jhkcool updated IMPALA-11612:
-----------------------------
    Description: 
Create execute plan failed : org.apache.impala.common.AnalysisException: ORDER 
BY expression not produced by aggregation output (missing from GROUP BY 
clause?): (CASE WHEN (to_date(CAST(t1.dt AS TIMESTAMP)) = TIMESTAMP '2022-05-12 
00:00:00') THEN '2022-05-12' WHEN (to_date(CAST(t1.dt AS TIMESTAMP)) = 
TIMESTAMP '2022-05-13 00:00:00') THEN '2022-05-13' END) at 
org.apache.impala.analysis.SelectStmt$SelectAnalyzer.verifyAggregation(SelectStmt.java:1090)
 at 
org.apache.impala.analysis.SelectStmt$SelectAnalyzer.analyze(SelectStmt.java:312)
 at 
org.apache.impala.analysis.SelectStmt$SelectAnalyzer.access$100(SelectStmt.java:276)
 at org.apache.impala.analysis.SelectStmt.analyze(SelectStmt.java:269) at 
org.apache.impala.analysis.AnalysisContext.reAnalyze(AnalysisContext.java:611) 
at org.apache.impala.analysis.AnalysisContext.analyze(AnalysisContext.java:585) 
at 
org.apache.impala.analysis.AnalysisContext.analyzeAndAuthorize(AnalysisContext.java:468)
 at org.apache.impala.service.Frontend.doCreateExecRequest(Frontend.java:2084) 
at org.apache.impala.service.Frontend.getTExecRequest(Frontend.java:1967) at 
org.apache.impala.service.Frontend.createExecRequest(Frontend.java:1791) at 
org.apache.impala.service.Frontend$4.run(Frontend.java:2867) at 
org.apache.impala.service.Frontend$4.run(Frontend.java:2863) at 
java.security.AccessController.doPrivileged(Native Method) at 
javax.security.auth.Subject.doAs(Subject.java:360) at 
org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1864)
 at 
org.apache.impala.service.Frontend.createExecRequestWithProxy(Frontend.java:2863)
 at 
org.apache.impala.service.JniFrontend.createExecRequest(JniFrontend.java:208)

query_option:
ENABLE_EXPR_REWRITES : true
while execute query sql:

{noformat}
SELECT (1 = 1 AND CASE WHEN (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = 
CAST('2022-05-12' AS TIMESTAMP)) THEN '2022-05-12' WHEN (TO_DATE(CAST(`t1`.`dt` 
AS TIMESTAMP)) = CAST('2022-05-13' AS TIMESTAMP)) THEN '2022-05-13' END) d0
FROM `jhk_test`.`p1` `t1`
WHERE (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) >= CAST('2022-05-12' AS 
TIMESTAMP)) AND (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) < CAST('2022-05-19' AS 
TIMESTAMP))
GROUP BY (1 = 1 AND CASE WHEN (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = 
CAST('2022-05-12' AS TIMESTAMP)) THEN '2022-05-12' WHEN (TO_DATE(CAST(`t1`.`dt` 
AS TIMESTAMP)) = CAST('2022-05-13' AS TIMESTAMP)) THEN '2022-05-13' END)
ORDER BY (1 = 1 AND CASE WHEN (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = 
CAST('2022-05-12' AS TIMESTAMP)) THEN '2022-05-12' WHEN (TO_DATE(CAST(`t1`.`dt` 
AS TIMESTAMP)) = CAST('2022-05-13' AS TIMESTAMP)) THEN '2022-05-13' END)
limit 10
{noformat}


  was:
Create execute plan failed : org.apache.impala.common.AnalysisException: ORDER 
BY expression not produced by aggregation output (missing from GROUP BY 
clause?): (CASE WHEN (to_date(CAST(t1.dt AS TIMESTAMP)) = TIMESTAMP '2022-05-12 
00:00:00') THEN '2022-05-12' WHEN (to_date(CAST(t1.dt AS TIMESTAMP)) = 
TIMESTAMP '2022-05-13 00:00:00') THEN '2022-05-13' END) at 
org.apache.impala.analysis.SelectStmt$SelectAnalyzer.verifyAggregation(SelectStmt.java:1090)
 at 
org.apache.impala.analysis.SelectStmt$SelectAnalyzer.analyze(SelectStmt.java:312)
 at 
org.apache.impala.analysis.SelectStmt$SelectAnalyzer.access$100(SelectStmt.java:276)
 at org.apache.impala.analysis.SelectStmt.analyze(SelectStmt.java:269) at 
org.apache.impala.analysis.AnalysisContext.reAnalyze(AnalysisContext.java:611) 
at org.apache.impala.analysis.AnalysisContext.analyze(AnalysisContext.java:585) 
at 
org.apache.impala.analysis.AnalysisContext.analyzeAndAuthorize(AnalysisContext.java:468)
 at org.apache.impala.service.Frontend.doCreateExecRequest(Frontend.java:2084) 
at org.apache.impala.service.Frontend.getTExecRequest(Frontend.java:1967) at 
org.apache.impala.service.Frontend.createExecRequest(Frontend.java:1791) at 
org.apache.impala.service.Frontend$4.run(Frontend.java:2867) at 
org.apache.impala.service.Frontend$4.run(Frontend.java:2863) at 
java.security.AccessController.doPrivileged(Native Method) at 
javax.security.auth.Subject.doAs(Subject.java:360) at 
org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1864)
 at 
org.apache.impala.service.Frontend.createExecRequestWithProxy(Frontend.java:2863)
 at 
org.apache.impala.service.JniFrontend.createExecRequest(JniFrontend.java:208)

query_option:
ENABLE_EXPR_REWRITES : true
while execute query sql:

{noformat}
SELECT (CASE WHEN (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = CAST('2022-05-12' AS 
TIMESTAMP)) THEN '2022-05-12' WHEN (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = 
CAST('2022-05-13' AS TIMESTAMP)) THEN '2022-05-13' END) d0
FROM `jhk_test`.`p1` `t1`
WHERE (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) >= CAST('2022-05-12' AS 
TIMESTAMP)) AND (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) < CAST('2022-05-19' AS 
TIMESTAMP))
GROUP BY (CASE WHEN (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = CAST('2022-05-12' 
AS TIMESTAMP)) THEN '2022-05-12' WHEN (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = 
CAST('2022-05-13' AS TIMESTAMP)) THEN '2022-05-13' END)
ORDER BY (CASE WHEN (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = CAST('2022-05-12' 
AS TIMESTAMP)) THEN '2022-05-12' WHEN (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = 
CAST('2022-05-13' AS TIMESTAMP)) THEN '2022-05-13' END)
limit 10
{noformat}



> ORDER BY expression not produced by aggregation output
> ------------------------------------------------------
>
>                 Key: IMPALA-11612
>                 URL: https://issues.apache.org/jira/browse/IMPALA-11612
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Frontend
>    Affects Versions: Impala 4.1.0
>            Reporter: jhkcool
>            Priority: Major
>
> Create execute plan failed : org.apache.impala.common.AnalysisException: 
> ORDER BY expression not produced by aggregation output (missing from GROUP BY 
> clause?): (CASE WHEN (to_date(CAST(t1.dt AS TIMESTAMP)) = TIMESTAMP 
> '2022-05-12 00:00:00') THEN '2022-05-12' WHEN (to_date(CAST(t1.dt AS 
> TIMESTAMP)) = TIMESTAMP '2022-05-13 00:00:00') THEN '2022-05-13' END) at 
> org.apache.impala.analysis.SelectStmt$SelectAnalyzer.verifyAggregation(SelectStmt.java:1090)
>  at 
> org.apache.impala.analysis.SelectStmt$SelectAnalyzer.analyze(SelectStmt.java:312)
>  at 
> org.apache.impala.analysis.SelectStmt$SelectAnalyzer.access$100(SelectStmt.java:276)
>  at org.apache.impala.analysis.SelectStmt.analyze(SelectStmt.java:269) at 
> org.apache.impala.analysis.AnalysisContext.reAnalyze(AnalysisContext.java:611)
>  at 
> org.apache.impala.analysis.AnalysisContext.analyze(AnalysisContext.java:585) 
> at 
> org.apache.impala.analysis.AnalysisContext.analyzeAndAuthorize(AnalysisContext.java:468)
>  at 
> org.apache.impala.service.Frontend.doCreateExecRequest(Frontend.java:2084) at 
> org.apache.impala.service.Frontend.getTExecRequest(Frontend.java:1967) at 
> org.apache.impala.service.Frontend.createExecRequest(Frontend.java:1791) at 
> org.apache.impala.service.Frontend$4.run(Frontend.java:2867) at 
> org.apache.impala.service.Frontend$4.run(Frontend.java:2863) at 
> java.security.AccessController.doPrivileged(Native Method) at 
> javax.security.auth.Subject.doAs(Subject.java:360) at 
> org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1864)
>  at 
> org.apache.impala.service.Frontend.createExecRequestWithProxy(Frontend.java:2863)
>  at 
> org.apache.impala.service.JniFrontend.createExecRequest(JniFrontend.java:208)
> query_option:
> ENABLE_EXPR_REWRITES : true
> while execute query sql:
> {noformat}
> SELECT (1 = 1 AND CASE WHEN (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = 
> CAST('2022-05-12' AS TIMESTAMP)) THEN '2022-05-12' WHEN 
> (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = CAST('2022-05-13' AS TIMESTAMP)) 
> THEN '2022-05-13' END) d0
> FROM `jhk_test`.`p1` `t1`
> WHERE (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) >= CAST('2022-05-12' AS 
> TIMESTAMP)) AND (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) < CAST('2022-05-19' AS 
> TIMESTAMP))
> GROUP BY (1 = 1 AND CASE WHEN (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = 
> CAST('2022-05-12' AS TIMESTAMP)) THEN '2022-05-12' WHEN 
> (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = CAST('2022-05-13' AS TIMESTAMP)) 
> THEN '2022-05-13' END)
> ORDER BY (1 = 1 AND CASE WHEN (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = 
> CAST('2022-05-12' AS TIMESTAMP)) THEN '2022-05-12' WHEN 
> (TO_DATE(CAST(`t1`.`dt` AS TIMESTAMP)) = CAST('2022-05-13' AS TIMESTAMP)) 
> THEN '2022-05-13' END)
> limit 10
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to