I have added a runnable test case in the issue's description. The expected query could be a little bit different but this is runnable in Postgresql. Check it, please: https://issues.apache.org/jira/browse/CALCITE-1382. Thanks.
Best regards, Miguel. 2016-09-22 19:27 GMT+01:00 Julian Hyde <jh...@apache.org>: > Thanks. Please provide a runnable test case, otherwise it’s unlikely we’ll > be able to make progress. > > > On Sep 22, 2016, at 11:19 AM, Miguel Oliveira < > migueloliveira1...@gmail.com> wrote: > > > > I have logged https://issues.apache.org/jira/browse/CALCITE-1382 for > this > > issue. > > > > Tomorrow i will try to find a better query. > > > > Best regards, > > Miguel. > > > > 2016-09-22 18:55 GMT+01:00 Julian Hyde <jh...@apache.org>: > > > >> Yes, sure. Please create a runnable test case if you can. It sounds a > bit > >> improbable as you describe it. > >> > >>> On Sep 22, 2016, at 8:44 AM, Miguel Oliveira < > >> migueloliveira1...@gmail.com> wrote: > >>> > >>> Hi, > >>> > >>> I'm using the Jdbc Adapter and the SCOTT schema (emp, dept and > salgrade). > >>> > >>> When i execute the following query (i know that the second join doesn't > >>> make sense, but it's only to show the error): > >>> > >>>> SELECT count(*) FROM (SELECT count(emp.empno) `Count Emp`, dept.dname > >>>> `Department Name` FROM Calcite.emp emp JOIN Calcite.dept dept ON > >> emp.deptno > >>>> = dept.deptno JOIN Calcite.salgrade salgrade ON emp.comm = > >> salgrade.hisal > >>>> WHERE dept.dname LIKE '%O%' GROUP BY emp.deptno, dept.dname) > >>> > >>> > >>> a CastException is thrown: > >>> "org.apache.calcite.adapter.jdbc.JdbcRules$JdbcJoin cannot be cast to > >>> org.apache.calcite.adapter.enumerable.EnumerableRel". > >>> > >>> generates a plan: > >>> > >>>> [TABLE, #ID {PLAN=EnumerableAggregate(group=[{}], EXPR$0=[COUNT()]) > >>>> EnumerableAggregate(group=[{2, 4}]) > >>>> JdbcJoin(condition=[=($1, $0)], joinType=[inner]) > >>>> JdbcProject(hisal=[$2]) > >>>> JdbcTableScan(table=[[Calcite, salgrade]]) > >>>> JdbcJoin(condition=[=($1, $2)], joinType=[inner]) > >>>> JdbcProject(comm=[$6], deptno=[$7]) > >>>> JdbcTableScan(table=[[Calcite, emp]]) > >>>> JdbcProject(deptno=[$0], dname=[$1]) > >>>> JdbcFilter(condition=[LIKE($1, '%O%')]) > >>>> JdbcTableScan(table=[[Calcite, dept]]) > >>>> , }] > >>> > >>> > >>> Can i create an issue for this? > >>> > >>> Best regards, > >>> Miguel. > >> > >> > >