You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2016/09/23 16:26:20 UTC
[jira] [Commented] (CALCITE-1382) ClassCastException in JDBC
Adapter
[ https://issues.apache.org/jira/browse/CALCITE-1382?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15516897#comment-15516897 ]
Julian Hyde commented on CALCITE-1382:
--------------------------------------
Got it. I've pushed a branch with this test case: https://github.com/julianhyde/calcite/tree/1382-jdbc-class-cast.
> 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
> Labels: adapters, jdbc
> Fix For: 1.10.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
(v6.3.4#6332)