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

yanjing.wang edited comment on CALCITE-4512 at 4/25/21, 1:17 PM:
-----------------------------------------------------------------

I have run another test
{code:java}
select a.deptno + b.deptno as deptno from emp a , dept b group by deptno
{code}
the query results 2, 3, 4. dept table has the following relation

deptno

1

2

so I think the *deptno* in GROUP BY CLAUSE hasn't been resolved to *any real 
column when ambiguous columns exist*, alias instead.

I also have the following tests on Presto and Spark
{code:java}
select deptno as dno from emp group by cube(dno)   
{code}
and they both don't support alias in cube expression, I think calcite should 
behave in same way.


was (Author: yanjing.wang):
I have run another test
{code:java}
select a.deptno + b.deptno as deptno from emp a , dept b group by deptno
{code}
the query results 2, 3, 4. dept table has the following relation

deptno

1

2

so I think the *deptno* in GROUP BY CLAUSE hasn't been resolved to *any real 
column when ambiguous columns exist*, alias instead.

 

> group by expression has argument name same with select list item alias, 
> causes validation error
> -----------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4512
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4512
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.26.0
>         Environment: jvm: open-jdk8
>            Reporter: yanjing.wang
>            Priority: Major
>
> String sql = "select replace(name, 'a', 'b') as name from users group by 
> replace(name, 'a', 'b')";
>  
> when group by expression has argument name same with select list item alias, 
> the group by argument will be expanded to select list item when sql 
> conformance supports 'groupByAlias', so the above sql will be expanded to 
> String sql = "select replace(name, 'a', 'b') as name from users group by 
> replace(replace(name, 'a', 'b'), 'a', 'b')";
>  
> this is unexpected.



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

Reply via email to