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

Richárd Antal resolved PHOENIX-6413.
------------------------------------
    Fix Version/s: 5.1.3
                   4.16.2
                   5.2.0
                   4.17.0
       Resolution: Fixed

I cherry-picked the commit from master to all active branches.

> Having cannot resolve alias
> ---------------------------
>
>                 Key: PHOENIX-6413
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6413
>             Project: Phoenix
>          Issue Type: New Feature
>    Affects Versions: 4.14.3
>            Reporter: Baiqiang Zhao
>            Assignee: Baiqiang Zhao
>            Priority: Major
>             Fix For: 4.17.0, 5.2.0, 4.16.2, 5.1.3
>
>
> For example:
> {code:java}
> CREATE TABLE test_table (a_string varchar not null, col1 integer CONSTRAINT 
> pk PRIMARY KEY (a_string));
> select a_string, sum(col1) as sumCol1 from test_table group by a_string 
> having sumCol1>20 order by sumCol1;
> {code}
> Error log:
> {code:java}
> Caused by: org.apache.phoenix.schema.ColumnNotFoundException: ERROR 504 
> (42703): Undefined column. columnName=TEST_TABLE.SUMCOL1Caused by: 
> org.apache.phoenix.schema.ColumnNotFoundException: ERROR 504 (42703): 
> Undefined column. columnName=TEST_TABLE.SUMCOL1 at 
> org.apache.phoenix.schema.PTableImpl.getColumnForColumnName(PTableImpl.java:828)
>  at 
> org.apache.phoenix.compile.FromCompiler$SingleTableColumnResolver.resolveColumn(FromCompiler.java:477)
>  at 
> org.apache.phoenix.compile.HavingCompiler$HavingClauseVisitor.visit(HavingCompiler.java:173)
>  at 
> org.apache.phoenix.compile.HavingCompiler$HavingClauseVisitor.visit(HavingCompiler.java:104)
>  at org.apache.phoenix.parse.ColumnParseNode.accept(ColumnParseNode.java:56) 
> at 
> org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:64)
>  at 
> org.apache.phoenix.parse.ComparisonParseNode.accept(ComparisonParseNode.java:45)
>  at org.apache.phoenix.compile.HavingCompiler.rewrite(HavingCompiler.java:75) 
> at 
> org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:548)
>  at 
> org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:507)
>  at 
> org.apache.phoenix.compile.QueryCompiler.compileSelect(QueryCompiler.java:193)
>  at org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:153) 
> at 
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:493)
>  at 
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:459)
>  at 
> org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:302) at 
> org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:291) at 
> org.apache.phoenix.call.CallRunner.run(CallRunner.java:53) at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:290)
>  at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:283)
>  at 
> org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1834) 
> at 
> org.apache.calcite.avatica.jdbc.JdbcMeta.prepareAndExecute(JdbcMeta.java:747) 
> ... 24 more
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to