@Test public void testUnparseIn2() { final RexNode filter = builder.call(SqlStdOperatorTable.IN, builder.field("DEPTNO"), builder.literal(20), builder.literal(21)); final String sql = unparseRelTree(empScan.filter(filter).build()); final String expectedSql = "SELECT *\n" + "FROM \"scott\".\"EMP\"\n" + "WHERE \"DEPTNO\" IN (20, 21)"; assertThat(sql, isLinux(expectedSql)); }
/** * Tests that IN can be un-parsed. * * <p>This cannot be tested using "sql", because because Calcite's SQL parser * replaces INs with ORs or sub-queries. */ @Test public void testUnparseIn1() { final RexNode condition = builder.call(SqlStdOperatorTable.IN, builder.field("DEPTNO"), builder.literal(21)); final String sql = unparseRelTree(empScan.filter(condition).build()); final String expectedSql = "SELECT *\n" + "FROM \"scott\".\"EMP\"\n" + "WHERE \"DEPTNO\" IN (21)"; assertThat(sql, isLinux(expectedSql)); }
@Test public void testUnparseInStruct1() { final RexNode condition = builder.call(SqlStdOperatorTable.IN, builder.call(SqlStdOperatorTable.ROW, builder.field("DEPTNO"), builder.field("JOB")), builder.call(SqlStdOperatorTable.ROW, builder.literal(1), builder.literal("PRESIDENT"))); final String sql = unparseRelTree(empScan.filter(condition).build()); final String expectedSql = "SELECT *\n" + "FROM \"scott\".\"EMP\"\n" + "WHERE ROW(\"DEPTNO\", \"JOB\") IN (ROW(1, 'PRESIDENT'))"; assertThat(sql, isLinux(expectedSql)); }
@Test public void testUnparseInStruct2() { final RexNode condition = builder.call(SqlStdOperatorTable.IN, builder.call(SqlStdOperatorTable.ROW, builder.field("DEPTNO"), builder.field("JOB")), builder.call(SqlStdOperatorTable.ROW, builder.literal(1), builder.literal("PRESIDENT")), builder.call(SqlStdOperatorTable.ROW, builder.literal(2), builder.literal("PRESIDENT"))); final String sql = unparseRelTree(empScan.filter(condition).build()); final String expectedSql = "SELECT *\n" + "FROM \"scott\".\"EMP\"\n" + "WHERE ROW(\"DEPTNO\", \"JOB\") IN (ROW(1, 'PRESIDENT'), ROW(2, 'PRESIDENT'))"; assertThat(sql, isLinux(expectedSql)); }