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

Danny Chan commented on CALCITE-2999:
-------------------------------------

I checked sql-standard 2011 and the sort specification list definition is:
{code:java}
<sort specification list> ::=

<sort specification> [ { <comma> <sort specification> }... ]

<sort specification> ::=

<sort key> [ <ordering specification> ] [ <null ordering> ]

<sort key> ::=

<value expression>

<ordering specification> ::=

ASC

| DESC

<null ordering> ::=

NULLS FIRST
{code}
So it means the sort key can be any value expression that can be used as the 
operand of the 

ordering operation. For your case, it is a valid query.

I think there maybe be a bug for sql validator to produce wrong scope for the 
LogicalSort input, i will take this issue and try to fix.

> Can't get the right column value in LogicalSort
> -----------------------------------------------
>
>                 Key: CALCITE-2999
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2999
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.19.0
>            Reporter: yuqi
>            Priority: Critical
>         Attachments: problem.png
>
>
> Let's consider the sql:
> {code:sql}
> // Some comments here
> select 'hello', tag from b where text = '2' or text = '1' order by cast(text 
> as int) + 1 asc , tag desc limit 1"
> {code}
> And the Plan can be seen in the picture below
> We can't get the right column value of LogicalSort if sort condition is not 
> the select column list
> Can anyone help to explain this problem if i'm wrong



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to