Jiajun Xie created CALCITE-5597:
-----------------------------------

             Summary: Column that be order by should not be aggregate
                 Key: CALCITE-5597
                 URL: https://issues.apache.org/jira/browse/CALCITE-5597
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: Jiajun Xie


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)

Reply via email to