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

[jira] [Commented] (CALCITE-6063) ARRAY sub-query with OrderBy gives unexpected results

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

Julian Hyde commented on CALCITE-6063:
--------------------------------------

ORDER BY and LIMIT, per Postgres, seem to be desirable. I don’t recall why ORDER BY doesn’t work in Calcite; there was some talk a while back of how ORDER BY should be ignored in subqueries (which makes sense in general, just not for ARRAY). Or maybe we just never tested it, and therefore it never worked. 

Can you check that ARRAY syntax is correctly described in reference.md. 

> ARRAY sub-query with OrderBy gives unexpected results
> -----------------------------------------------------
>
>                 Key: CALCITE-6063
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6063
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.35.0
>            Reporter: Ran Tao
>            Priority: Major
>
> calcite support array query constructor.
> but If we run sub-query with orderby:
> {code:java}
> select array(select x from unnest(array[1,2,3]) as t(x) order by x desc); 
> select array(select x from unnest(array[1,2,3]) as t(x) order by x asc); {code}
> they both return
> {code:java}
> +-----------+
> |  EXPR$0   |
> +-----------+
> | [1, 2, 3] |
> +-----------+
>  {code}
> however, we expect return *[3, 2, 1]* when use {*}order by x desc{*}.
> It seems that the *order by* not works properly in array sub-query.
>  



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