[
https://issues.apache.org/jira/browse/CALCITE-4512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17340837#comment-17340837
]
yanjing.wang edited comment on CALCITE-4512 at 5/8/21, 8:48 AM:
----------------------------------------------------------------
OK, I run the test *select empno + deptno as empno from emp group by empno* on
BigQuery and found that BigQuery prefer alias when Group By alias and column
name are the same. MySQL prefer column name instead, see the comment #7 . if
we align with BigQuery, I think your original hypothesis comment #4 is the
final conclusion. I fixed the code and please review.
was (Author: yanjing.wang):
OK, I run the test *select empno + deptno as empno from emp group by empno* on
BigQuery and found that BigQuery prefer alias when Group By alias and column
name are the same. MySQL prefer column name instead, see the [comment #7
|https://issues.apache.org/jira/browse/CALCITE-4512?focusedCommentId=17330036&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17330036].
if we align with BigQuery, I think your original hypothesis [comment
#4|https://issues.apache.org/jira/browse/CALCITE-4512?focusedCommentId=17326811&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17326811]
is the final conclusion.
> 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
> Labels: pull-request-available
> Time Spent: 1h 40m
> Remaining Estimate: 0h
>
> 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)