[
https://issues.apache.org/jira/browse/CALCITE-5127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17630445#comment-17630445
]
Dmitry Sysolyatin commented on CALCITE-5127:
--------------------------------------------
[~libenchao]
The following query fails with NPE:
{code:java}
SELECT
(SELECT 1 FROM pg_catalog.pg_attribute d WHERE d.attrelid = a.attrelid LIMIT
1) AS t,
(SELECT a.attidentity = 'a' FROM pg_catalog.pg_attribute s LIMIT 1) as
identity_options
FROM pg_catalog.pg_attribute a;
LogicalProject(t=[$SCALAR_QUERY({
LogicalSort(fetch=[1])
LogicalProject(EXPR$0=[1])
LogicalFilter(condition=[=($0, $cor0.attrelid)])
LogicalTableScan(table=[[default, pg_catalog, pg_attribute]])
})], identity_options=[$SCALAR_QUERY({
LogicalSort(fetch=[1])
LogicalProject(EXPR$0=[=($cor0.attidentity, _UTF-16LE'a')])
LogicalTableScan(table=[[default, pg_catalog, pg_attribute]])
})])
LogicalTableScan(table=[[default, pg_catalog, pg_attribute]])
java.lang.NullPointerException: null
at java.base/java.util.Objects.requireNonNull(Objects.java:221)
at
org.apache.calcite.sql2rel.RelDecorrelator.createValueGenerator(RelDecorrelator.java:833)
at
org.apache.calcite.sql2rel.RelDecorrelator.decorrelateInputWithValueGenerator(RelDecorrelator.java:1028)
{code}
I tried to come up minimal testcase but I faced with another issue:
{code:java}
SELECT
(SELECT 1 FROM emp d WHERE d.gender = a.gender LIMIT 1) AS t1,
(SELECT a.gender = 'F' FROM emp s LIMIT 1) as t2
FROM emp a;
Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
> at
> com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:77)
> at org.apache.calcite.tools.RelBuilder.inferAlias(RelBuilder.java:2231)
> at org.apache.calcite.tools.RelBuilder.project_(RelBuilder.java:1997)
{code}
Test case code -
[https://github.com/apache/calcite/commit/57c8e187b62674d74428186d09d1237420dcc836]
> Support correlation variables in Project
> ----------------------------------------
>
> Key: CALCITE-5127
> URL: https://issues.apache.org/jira/browse/CALCITE-5127
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Dmitry Sysolyatin
> Assignee: Benchao Li
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.33.0
>
> Time Spent: 3h 50m
> Remaining Estimate: 0h
>
> The following queries fail:
> {code}
> SELECT ARRAY(SELECT s.x) FROM (SELECT ARRAY[1,2,3] as x) s;
> SELECT ARRAY(SELECT * FROM UNNEST(s.x) y) FROM (SELECT ARRAY[1,2,3] as x) s;
> SELECT (SELECT CARDINALITY(s.x) LIMIT 1) FROM (SELECT ARRAY[1,2,3] as x) s;
>
> {code}
> With exception:
> {code}
> Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to
> java.util.List
> {code}
> You can find test cases for this task in
> https://github.com/apache/calcite/commit/27e68ded2c3bea7d7af73dd1dc156e46fb3591a8
--
This message was sent by Atlassian Jira
(v8.20.10#820010)