You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "luoping.zhang (Jira)" <ji...@apache.org> on 2023/04/22 04:14:00 UTC

[jira] [Comment Edited] (CALCITE-5656) RelToSqlConverter has an error using ordinal for ORDER BY

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

luoping.zhang edited comment on CALCITE-5656 at 4/22/23 4:13 AM:
-----------------------------------------------------------------

[~jiajunbernoulli] This will add extra subqueries.

 
{code:java}
"select count(1) as c\n"
    + "from \"foodmart\".\"product\"\n"
    + "group by \"product_id\"\n"
    + "order by count(1),\"product_id\" desc"; {code}
 Expected:
{code:java}
SELECT COUNT(*) AS \"C\"
FROM \"foodmart\".\"product\"
GROUP BY \"product_id\"
ORDER BY 1,\"product_id\" DESC {code}
Actual:
{code:java}
SELECT \"C\"
FROM (SELECT COUNT(*) AS \"C\", \"product_id\"
FROM \"foodmart\".\"product\"
GROUP BY \"product_id\"
ORDER BY 1, \"product_id\" DESC) AS \"t2\" {code}
Based on your PR,the ordinal range judgment should be added.

 

 


was (Author: JIRAUSER299898):
[~jiajunbernoulli] This will add extra subqueries.

 
{code:java}
"select count(1) as c\n"
    + "from \"foodmart\".\"product\"\n"
    + "group by \"product_id\"\n"
    + "order by count(1),\"product_id\" desc"; {code}
 Expected:
{code:java}
SELECT COUNT(*) AS \"C\"
FROM \"foodmart\".\"product\"
GROUP BY \"product_id\"
ORDER BY 1,\"product_id\" DESC {code}
Actual:
{code:java}
SELECT \"C\"
FROM (SELECT COUNT(*) AS \"C\", \"product_id\"
FROM \"foodmart\".\"product\"
GROUP BY \"product_id\"
ORDER BY 1, \"product_id\" DESC) AS \"t2\" {code}
 

> RelToSqlConverter has an error using ordinal for ORDER BY
> ---------------------------------------------------------
>
>                 Key: CALCITE-5656
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5656
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.34.0
>            Reporter: luoping.zhang
>            Assignee: luoping.zhang
>            Priority: Critical
>              Labels: pull-request-available
>         Attachments: image-2023-04-19-12-26-32-719.png
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
>  For example:
> Query SQL is 
> {code:java}
>  select a from table order by coalesce(a,b){code}
> When we convert this sql to relNode and convert it back to SQL by RelToConverter, the result is:
> {code:java}
> select a from table order by 2{code}
> But this sql syntax is wrong because there is no ordinal 2



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