You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2023/03/23 05:34:00 UTC
[jira] [Commented] (CALCITE-5597) Column that be order by should not be aggregated
[ https://issues.apache.org/jira/browse/CALCITE-5597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17703891#comment-17703891 ]
Julian Hyde commented on CALCITE-5597:
--------------------------------------
This only applies to a {{SELECT DISTINCT}} query with {{ORDER BY}}, right? If so you should say so in the summary.
I agree that this is a bug. It's difficult to think of a function other than {{RAND()}} that would have this problem. (If it had any arguments it couldn't be pushed down; and if it were pure it wouldn't matter whether it were pushed down or not.)
> Column that be order by should not be aggregated
> ------------------------------------------------
>
> Key: CALCITE-5597
> URL: https://issues.apache.org/jira/browse/CALCITE-5597
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Jiajun Xie
> Priority: Major
>
> Here is unit test
> {code:java}
> @Test void testDistinctOrderByRand() {
> final String sql = "select distinct deptno from emp order by rand()";
> sql(sql).ok();
> } {code}
> We will get error logical plan
> {code:java}
> LogicalProject(DEPTNO=[$0])
> LogicalSort(sort0=[$1], dir0=[ASC])
> LogicalAggregate(group=[{0, 1}]) //rand() in group, result will be error
> LogicalProject(DEPTNO=[$7], EXPR$1=[RAND()])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)