You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "peng wang (Jira)" <ji...@apache.org> on 2023/02/02 08:54:00 UTC

[jira] [Comment Edited] (CALCITE-5510) RelToSqlConverter don't support sort by ordinal when sort by column is a expression

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

peng wang edited comment on CALCITE-5510 at 2/2/23 8:53 AM:
------------------------------------------------------------

It may be decided by dialect configuration?
In my opinion,If the configuration in dialect mark using ordinary in ORDER BY, the result will be 
{code:java}
select a, sum(b) from table group by a order by 2{code}
If the configuration in dialect mark not using ordinary in ORDER BY, the result will be 
{code:java}
select a, sum(b) from table group by a order by sum(b){code}


was (Author: peng713128):
It may be decided by dialect configuration?
In my opinion,If the configuration in dialect mark using ordinary in ORDER BY, the result will be 
{code:java}
select a, sum(b) from table group by a order by 1{code}
If the configuration in dialect mark not using ordinary in ORDER BY, the result will be 
{code:java}
select a, sum(b) from table group by a order by a{code}

> RelToSqlConverter don't support sort by ordinal when sort by column is a expression
> -----------------------------------------------------------------------------------
>
>                 Key: CALCITE-5510
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5510
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.26.0
>            Reporter: peng wang
>            Priority: Major
>
> For example:
> Query SQL is 
> {code:java}
> select a, sum(b) from table group by a order by 2{code}
> When we convert this sql to relNode and convert it back to SQL by RelToConverter, the result is:
> {code:java}
> select a, sum(b) from table group by a order by sum(b){code}
> But we want to keep order by column to ordinal.
> Would we add a switch in RelToConverter to control whether convert sort by column to expression or ordinal?
> Maybe we can use method isSortByOrdinal in dialect SqlConformance?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)