[
https://issues.apache.org/jira/browse/CALCITE-7135?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ruben Q L resolved CALCITE-7135.
--------------------------------
Resolution: Fixed
Fixed via
[{{9710ccf}}|https://github.com/apache/calcite/commit/9710ccf28cab2f210a5a3e836b55b47da519f085]
> 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: Ruben Q L
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.41.0
>
>
> 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)