[ https://issues.apache.org/jira/browse/CALCITE-1382?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julian Hyde resolved CALCITE-1382. ---------------------------------- Resolution: Fixed Test case added in [d3d157fc|https://github.com/apache/calcite/commit/d3d157fcf99686d341a104b4763d0424544b904a]. Marking "fixed in 1.27" although it was probably fixed long ago. > ClassCastException in JDBC Adapter > ---------------------------------- > > Key: CALCITE-1382 > URL: https://issues.apache.org/jira/browse/CALCITE-1382 > Project: Calcite > Issue Type: Bug > Components: core > Affects Versions: 1.9.0 > Environment: This bug was detected using a postgresql database and > the calcite version 1.9.0. > Reporter: Miguel Oliveira > Assignee: Julian Hyde > Priority: Major > Labels: adapters, jdbc > Fix For: 1.27.0 > > > This query: > {code} > 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) > {code} > generates a ClassCastException: > "org.apache.calcite.adapter.jdbc.JdbcRules$JdbcJoin cannot be cast to > org.apache.calcite.adapter.enumerable.EnumerableRel". > The plan is the following: > {code} > [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]]) > , }] > {code} > Runnable test: > {code} > /** Test case for > * <a href="https://issues.apache.org/jira/browse/CALCITE-1382">[CALCITE-1382] > * ClassCastException in JDBC adapter</a>. */ > @org.junit.Test > public void testJoinPlan3() throws DataSourceManagerException { > final String sql = "SELECT count(*) FROM (SELECT count(emp.empno) `Count > Emp`, dept.dname `Department Name`\n" > + "FROM emp emp JOIN dept dept ON emp.deptno = dept.deptno\n" > + "JOIN salgrade salgrade ON emp.comm = salgrade.hisal\n" > + "WHERE dept.dname LIKE '%A%' GROUP BY emp.deptno, dept.dname)"; > final String expected = "SELECT COUNT(*) FROM (\n" + > "SELECT count(\"emp\".empno) AS \"Count Emp\", \"dept\".dname AS > \"Department Name\"\n" + > "FROM emp AS \"emp\"\n" + > "INNER JOIN (\n" + > "SELECT deptno, dname\n" + > "FROM dept\n" + > "WHERE dname LIKE '%A%'\n" + > ") AS \"dept\" ON \"emp\".deptno = \"dept\".deptno\n" + > "INNER JOIN (\n" + > "SELECT hisal \n" + > "FROM salgrade \n" + > ") AS \"salgrade\" ON \"emp\".comm = \"salgrade\".hisal " + > "GROUP BY \"emp\".deptno, \"dept\".dname" + > ") AS \"t\""; > sql(sql) > .schema(CalciteAssert.SchemaSpec.JDBC_SCOTT) > .ok(expected); > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)