Vladimir Ozerov created CALCITE-5175: ----------------------------------------
Summary: 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 Reporter: Vladimir Ozerov 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)