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

Julian Hyde commented on CALCITE-4512:
--------------------------------------

Thanks for continuing to push this, [~yanjing.wang]. Let's get this done for 
1.38.

Which DB are we trying to emulate the behavior of? If so, I would like to see a 
Quidem test that returns the same in Calcite and that DB, and would return the 
wrong result if the bug were not fixed. Perhaps something like {{select 
mod(empno, 3) as empno from emp group by mod(empno, 2)}} and make sure that we 
get the right number of rows.

Also I would like to see a SqlValidatorTest. Something like {{select 
date_add('2024-01-01', empno) as empno from emp group by year(empno)}}, where 
there will be a type error (int vs date) if the wrong column is referenced.

In short, more tests - that are broken before the fix, and pass after the fix, 
and are demonstrably the same behavior as a given DB - will give me the 
confidence to approve this PR.

> GROUP BY expression with argument name same with SELECT field and 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.38.0
>         Environment: jvm: open-jdk11
>            Reporter: yanjing.wang
>            Assignee: yanjing.wang
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.38.0
>
>          Time Spent: 3h
>  Remaining Estimate: 0h
>
> {code:java}
> String sql = "select replace(name, 'a', 'b') as name from users group by 
> replace(name, 'a', 'b')";
> {code}
>  
> 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 
> {code:java}
> String sql = "select replace(name, 'a', 'b') as name from users group by 
> replace(replace(name, 'a', 'b'), 'a', 'b')";
> {code}
>  
> this is unexpected.



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

Reply via email to