You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "krooswu (Jira)" <ji...@apache.org> on 2025/08/15 14:46:00 UTC

[jira] [Assigned] (CALCITE-7135) SqlToRelConverter throws AssertionError on ARRAY subquery order by a field that is not present on the final projection

     [ https://issues.apache.org/jira/browse/CALCITE-7135?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

krooswu reassigned CALCITE-7135:
--------------------------------

    Assignee: krooswu

> SqlToRelConverter throws AssertionError on ARRAY subquery order by a field that is not present on the final projection
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-7135
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7135
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.40.0
>            Reporter: Ruben Q L
>            Assignee: krooswu
>            Priority: Major
>
> This query works fine in SqlToRelConverter:
> {code:sql}
> SELECT ARRAY(SELECT empno FROM emp)
> {code}
> This also works:
> {code:sql}
> SELECT ARRAY(SELECT empno FROM emp ORDER BY empno)
> {code}
> However this one:
> {code:sql}
> SELECT ARRAY(SELECT empno FROM emp ORDER BY ename)
> {code}
> fails with
> {noformat}
> java.lang.AssertionError: Conversion to relational algebra failed to preserve datatypes:
> validated type:
> RecordType(INTEGER NOT NULL ARRAY NOT NULL EXPR$0) NOT NULL
> converted type:
> RecordType(RecordType(INTEGER NOT NULL EMPNO, VARCHAR(20) NOT NULL ENAME) NOT NULL ARRAY NOT NULL EXPR$0) NOT NULL
> ...
> at org.apache.calcite.sql2rel.SqlToRelConverter.checkConvertedType(SqlToRelConverter.java:524)
> at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:643)
> {noformat}
> This problem seems to be that the subquery to construct the array is order by a field that is not part of its final projection; Calcite usually deals with this situation using a RelRoot "wrapper", but in this scenario we just have a simple RelNode.



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