[
https://issues.apache.org/jira/browse/CALCITE-5127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17608231#comment-17608231
]
Benchao Li commented on CALCITE-5127:
-------------------------------------
[~zabetak] I also had the same feeling when I added these tests.
So, I checked the codebase about which phase will we apply {{RelFieldTrimmer}},
and I found that it's placed after {{SubQueryRemoveRule}} and
{{DecorrelateProgram}}, [see
here|https://github.com/apache/calcite/blob/f8dd80fcd2d4d92767936fe7b3dae349f2f0ec40/core/src/main/java/org/apache/calcite/tools/Programs.java#L282-L289],
that's good, and is what I expect we should use it. The reason why the test
fails without changing {{RelFieldTrimmer}} is that we do the trimming work
before optimization in
[{{Prepare}}|https://github.com/apache/calcite/blob/f8dd80fcd2d4d92767936fe7b3dae349f2f0ec40/core/src/main/java/org/apache/calcite/prepare/Prepare.java#L297].
That's why I think it's not so harmful to stop trim {{Project}} in
{{RelFieldTrimmer}}.
Of course, {{RelFieldTrimmer}} is not used in a single way as Calcite did now,
especially for down stream projects.
I'm ok with the both way. If you still prefer the former way after the my above
explanation, then let's go to [https://github.com/apache/calcite/pull/2813].
> Error when executing query with correlated sub-query in SELECT clause
> ---------------------------------------------------------------------
>
> 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: 2h 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)