[
https://issues.apache.org/jira/browse/CALCITE-5175?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17544942#comment-17544942
]
Vladimir Ozerov commented on CALCITE-5175:
------------------------------------------
Generally, it seems wrong that we used multiple validator/converter instances
to convert a single query. I tried a quick fix when only one
validator/converter pair is used throughout the query processing, and it solved
the problem. However, this straightforward approach may break other parts of
the system, because the converter is not re-entrant.
> IndexOutOfBoundsException when query has IN clause on top of the view column
> ----------------------------------------------------------------------------
>
> Key: CALCITE-5175
> URL: https://issues.apache.org/jira/browse/CALCITE-5175
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.30.0
> Reporter: Vladimir Ozerov
> Priority: Major
>
> A query may contain views. Currently, views are processed using separate
> validator/converter instances. Both validator and sql-to-rel-converter are
> stateful and it appears that their state might be important for "parent"
> validator/converter pair.
> To reproduce the problem, please add the code below to the {{PlannerTest}}.
> The query with {{IN}} would fail with {{IndexOutOfBoundsException}} because
> we treat the {{IN}} clause as a subquery that requires access to the context
> of the child view, which is not propagated when using separate
> validator/converter instances for views.
> {code}
> @Test void testViewnViewWithIn() throws Exception {
> final String sql = "select (dname in ('a', 'b')), count(deptno) FROM
> dept30 group by (dname in ('a', 'b'))";
> final String expected = "LogicalProject(DEPTNO=[$0], DNAME=[$1])\n"
> + " LogicalValues("
> + "tuples=[[{ 10, 'Sales ' },"
> + " { 20, 'Marketing ' },"
> + " { 30, 'Engineering' },"
> + " { 40, 'Empty ' }]])\n";
> checkView(sql, is(expected));
> }
> @Test void testViewnViewWithOr() throws Exception {
> final String sql = "select (dname = 'a' or dname = 'b'), count(deptno)
> FROM dept30 group by (dname = 'a' or dname = 'b')";
> final String expected = "LogicalProject(DEPTNO=[$0], DNAME=[$1])\n"
> + " LogicalValues("
> + "tuples=[[{ 10, 'Sales ' },"
> + " { 20, 'Marketing ' },"
> + " { 30, 'Engineering' },"
> + " { 40, 'Empty ' }]])\n";
> checkView(sql, is(expected));
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.7#820007)