You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Sheng Wang (Jira)" <ji...@apache.org> on 2023/02/01 06:58:00 UTC
[jira] [Commented] (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=17682884#comment-17682884 ]
Sheng Wang commented on CALCITE-5510:
-------------------------------------
RelToConverter will convert ordinal to real expr, so if original is:
{code:java}
select a, sum(b) from table group by a order by a
{code}
What is the expected result?
{code:java}
select a, sum(b) from table group by a order by a
{code}
or
{code:java}
select a, sum(b) from table group by a order by 1
{code}
Also, for this sql:
{code:java}
select a, sum(b) as b from table group by a order by b
{code}
What is the expected result?
{code:java}
select a, sum(b) as b from table group by a order by b
{code}
or
{code:java}
select a, sum(b) as b from table group by a order by 2
{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)