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

Julian Hyde commented on CALCITE-4987:
--------------------------------------

Are there any dialects that allow ordinal but not alias in the ORDER BY? Or 
vice versa? If so, how does this change affect them?

Does the SqlDelegatingConformance constructor really need to be public?

Does this issue relate to CALCITE-3440?

I see that the PR removes a really good comment
{code:java}
            // If the field expression is an unqualified column identifier
            // and matches a different alias, use an ordinal.
            // For example, given
            //    SELECT deptno AS empno, empno AS x FROM emp ORDER BY emp.empno
            // we generate
            //    SELECT deptno AS empno, empno AS x FROM emp ORDER BY 2
            // "ORDER BY empno" would give incorrect result;
            // "ORDER BY x" is acceptable but is not preferred. {code}
and adds a kind of useless one
{code:java}
//The order by ordinal may be greater than size of the new projects. {code}
That's basically a drop in code quality. Can you make sure that the new 
algorithm is as well documented as the old one.

> JDBC adapter generates incorrect query when ORDER BY alias collides with 
> field in SELECT ITEM
> ---------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4987
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4987
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.29.0
>         Environment: jdk8
>            Reporter: yanjing.wang
>            Assignee: yanjing.wang
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.30.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> I reproduce with the following query.
>  
> {code:java}
> SELECT sum(shelf_width) as shelf_width FROM product ORDER BY shelf_width{code}
> you must have noticed that the shelf_width alias is same with field 
> 'shelf_width' in sum.
> I expected the query hasn't changed when I test in RelToSqlConverterTest. But 
> I get unexpected query is 
> {code:java}
> SELECT sum(shelf_width) as shelf_width FROM product ORDER BY sum(shelf_width) 
>  {code}
>  the unexpected query is not valid in the dialect which support order by 
> alias conformance.
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to