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

Jinfeng Ni commented on CALCITE-634:
------------------------------------

I think the reason that you saw such SqlValidatorException is that Calcite does 
not allow ordinal reference in GROUP BY.  Ordinal reference is only allowed in 
ORDER BY clause. 

Some systems, e.g Postgre, do allow ordinal reference in GROUP BY.  The 
following query works in poster 9.3.  

{code}
select distinct dept_name from dept group by 1;
 dept_name
-----------
 abc
{code}

Seems it's desirable to open this restriction in Calcite, and allow ordinal 
reference in GROUP BY clause.  [~julianhyde],  what's your opinion on this ?

  



> Failure to order by if DISTINCT clause is present
> -------------------------------------------------
>
>                 Key: CALCITE-634
>                 URL: https://issues.apache.org/jira/browse/CALCITE-634
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Sean Hsuan-Yi Chu
>            Assignee: Julian Hyde
>
> For example, the query 
> {code:sql}
> select distinct count(empno) from emp
> group by empno
> order by 1
> {code}
> gave:
> org.apache.calcite.sql.validate.SqlValidatorException <init>
> SEVERE: org.apache.calcite.sql.validate.SqlValidatorException: Expression 
> 'COUNT(`EMP`.`EMPNO`)' is not in the select clause



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to