[
https://issues.apache.org/jira/browse/CALCITE-5127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17600701#comment-17600701
]
Stamatis Zampetakis commented on CALCITE-5127:
----------------------------------------------
Hi [~libenchao], as I was going again over the PR and in particular as I was
trying to reply to your comment
[here|https://github.com/apache/calcite/pull/2813/files#r945410944] I stuck
again to the point if we really need to add variablesSet in the {{Project}} to
fix the bug reported in this JIRA.
As you correctly identified, the queries reported here are failing due to the
incorrect removal of some projections when there are correlation variables on
the top project. The proposed fix, addresses the problem at the RelBuilder
level by disabling project elimination when the top project has correlation
variables. At its current state the PR solves the problem but at the same time
introduces changes at many places and some of them breaking.
An alternative way of fixing the problem would be to use
{{RexUtil.containsCorrelation}} in {{RelBuilder}} (and other places as needed)
to prevent the merge/removal of projections. It may be less fine grained than
the current proposal (it does not distinguish between variables set and used)
but seems like a less intrusive change with smaller risk for side effects. Do
you see a problem with this approach?
> Error when executing query with subquery in select list that uses outer
> column of array type
> --------------------------------------------------------------------------------------------
>
> 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.32.0
>
> Time Spent: 1h 10m
> 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)