/** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-2652">[CALCITE-2652] * SqlNode to SQL conversion fails if the join condition references a BOOLEAN * column</a>. */ @Test public void testJoinOnBoolean() { final String sql = "SELECT 1\n" + "from emps\n" + "join emp on (emp.deptno = emps.empno and manager)"; final String s = sql(sql).schema(CalciteAssert.SchemaSpec.POST).exec(); assertThat(s, notNullValue()); // sufficient that conversion did not throw }
/** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-1372">[CALCITE-1372] * JDBC adapter generates SQL with wrong field names</a>. */ @Test public void testJoinPlan2() { final String sql = "SELECT v1.deptno, v2.deptno\n" + "FROM dept v1 LEFT JOIN emp v2 ON v1.deptno = v2.deptno\n" + "WHERE v2.job LIKE 'PRESIDENT'"; final String expected = "SELECT \"DEPT\".\"DEPTNO\"," + " \"EMP\".\"DEPTNO\" AS \"DEPTNO0\"\n" + "FROM \"JDBC_SCOTT\".\"DEPT\"\n" + "LEFT JOIN \"JDBC_SCOTT\".\"EMP\"" + " ON \"DEPT\".\"DEPTNO\" = \"EMP\".\"DEPTNO\"\n" + "WHERE \"EMP\".\"JOB\" LIKE 'PRESIDENT'"; final String expected2 = "SELECT DEPT.DEPTNO, EMP.DEPTNO AS DEPTNO0\n" + "FROM JDBC_SCOTT.DEPT AS DEPT\n" + "LEFT JOIN JDBC_SCOTT.EMP AS EMP ON DEPT.DEPTNO = EMP.DEPTNO\n" + "WHERE EMP.JOB LIKE 'PRESIDENT'"; sql(sql) .schema(CalciteAssert.SchemaSpec.JDBC_SCOTT) .ok(expected) .withDb2() .ok(expected2); }
/** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-1372">[CALCITE-1372] * JDBC adapter generates SQL with wrong field names</a>. */ @Test public void testJoinPlan2() { final String sql = "SELECT v1.deptno, v2.deptno\n" + "FROM dept v1 LEFT JOIN emp v2 ON v1.deptno = v2.deptno\n" + "WHERE v2.job LIKE 'PRESIDENT'"; final String expected = "SELECT \"DEPT\".\"DEPTNO\"," + " \"EMP\".\"DEPTNO\" AS \"DEPTNO0\"\n" + "FROM \"JDBC_SCOTT\".\"DEPT\"\n" + "LEFT JOIN \"JDBC_SCOTT\".\"EMP\"" + " ON \"DEPT\".\"DEPTNO\" = \"EMP\".\"DEPTNO\"\n" + "WHERE \"EMP\".\"JOB\" LIKE 'PRESIDENT'"; final String expected2 = "SELECT DEPT.DEPTNO, EMP.DEPTNO AS DEPTNO0\n" + "FROM JDBC_SCOTT.DEPT AS DEPT\n" + "LEFT JOIN JDBC_SCOTT.EMP AS EMP ON DEPT.DEPTNO = EMP.DEPTNO\n" + "WHERE EMP.JOB LIKE 'PRESIDENT'"; sql(sql) .schema(CalciteAssert.SchemaSpec.JDBC_SCOTT) .ok(expected) .withDb2() .ok(expected2); }