Column aliases are only available in the ORDER BY clause. In some 
dialect-compliance settings, they are also available in the GROUP BY and HAVING 
clauses. But not in the WHERE clause.


> On Aug 19, 2022, at 2:22 PM, Sean Broeder <[email protected]> wrote:
> 
> 
> Hi,
> Calcite is capable of handling a simple column alias query such as 
> SELECT city as c
> FROM (values('PARIS')) as t(city)
> However, I add a simple predicate 
> 
> SELECT city as c
> FROM (values('PARIS')) as t(city)
> WHERE c is not null
> the query fails in validation indicating "Column 'C' not found in any table”
> Caused by: org.apache.calcite.runtime.CalciteContextException: At line 1, 
> column 58: Column 'C' not found in any table
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>       at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>       at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>       at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:505)
>       at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:932)
>       at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:917)
>       at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5266)
>       at 
> org.apache.calcite.sql.validate.DelegatingScope.fullyQualify(DelegatingScope.java:273)
> 
> I’m curious if this is the intended Calcite behavior?
> 
> This looks might be related to 
> https://issues.apache.org/jira/browse/CALCITE-4305, but I am not sure.
> 
> Thanks,
> Sean
> 
> 

Reply via email to