[
https://issues.apache.org/jira/browse/CALCITE-4512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17506879#comment-17506879
]
yanjing.wang commented on CALCITE-4512:
---------------------------------------
Hi all, I submit a [PR-2745|https://github.com/apache/calcite/pull/2745] for
this problem, this pr expands GROUP BY alias in the following way:
# GROUP BY Identifier/Ordinal, try to replace the Identifier/Ordinal with
SELECT ITEM.
# GROUP BY CUBE/ROLLUP/GROUPING SETS ((Identifier/Ordinal), ...), the
Identifier/Ordinal will be replaced as 1.
# GROUP BY f(Identifier/Ordinal), where f is a whatever function, don't
replace, try to solve the Identifier as an input field.
I have logged another CALCITE-5043 to solve [~wojustme] 's Problem, and
CALCITE-5045 for GROUPING SETS type mismatch problem, welcome discussion on
them.
> 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.26.0
> Environment: jvm: open-jdk8
> Reporter: yanjing.wang
> Assignee: yanjing.wang
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.31.0
>
> Time Spent: 2.5h
> 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.20.1#820001)