[ https://issues.apache.org/jira/browse/CALCITE-3207?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Xurenhe updated CALCITE-3207: ----------------------------- Description: Hi all I have a problem when using calcite, which is 'relnode convert sql statement' example: // RelToSqlConverterTest.java @Test public void testLeftJoinRel2Sql() \{ final RelBuilder builder = relBuilder(); final RelNode rel = builder .scan("EMP") .scan("DEPT") .join(JoinRelType.LEFT, builder.and( builder.call(SqlStdOperatorTable.EQUALS, builder.field(2, 0, "DEPTNO"), builder.field(2, 1, "DEPTNO") ), builder.call(SqlStdOperatorTable.LIKE, builder.field(2, 1, "DNAME"), builder.literal("ACCOUNTING")))) .build(); final String sql = toSql(rel); final String expectedSql = "SELECT *\n" + "FROM \"scott\".\"EMP\"\n" + "LEFT JOIN \"scott\".\"DEPT\" ON \"EMP\".\"DEPTNO\" = \"DEPT\".\"DEPTNO\"\n" + "AND \"DEPT\".\"DNAME\" LIKE 'ACCOUNTING'"; assertThat(sql, isLinux(expectedSql)); } this relNode cannot convert sql statement. I try to debug it, `org.apache.calcite.rel.rel2sql.SqlImplementor#convertConditionToSqlNode` may forgot to handle this case, which sqlKind is SqlKind.LIKE. If it is a bug, I am willing to fix it. Thanks. was: Hi all I have a problem when using calcite, which is 'relnode convert sql statement' example: ``` @Test public void testLeftJoinRel2Sql() { final RelBuilder builder = relBuilder(); final RelNode rel = builder .scan("EMP") .scan("DEPT") .join(JoinRelType.LEFT, builder.and( builder.call(SqlStdOperatorTable.EQUALS, builder.field(2, 0, "DEPTNO"), builder.field(2, 1, "DEPTNO") ), builder.call(SqlStdOperatorTable.LIKE, builder.field(2, 1, "DNAME"), builder.literal("ACCOUNTING")))) .build(); final String sql = toSql(rel); final String expectedSql = "SELECT *\n" + "FROM \"scott\".\"EMP\"\n" + "LEFT JOIN \"scott\".\"DEPT\" ON \"EMP\".\"DEPTNO\" = \"DEPT\".\"DEPTNO\"\n" + "AND \"DEPT\".\"DNAME\" LIKE 'ACCOUNTING'"; assertThat(sql, isLinux(expectedSql)); } ``` this relNode cannot convert sql statement. I try to debug it, `org.apache.calcite.rel.rel2sql.SqlImplementor#convertConditionToSqlNode` may forgot to handle this case, which sqlKind is SqlKind.LIKE. If it is a bug, I am willing to fix it. Thanks. > Bug of 'JoinRelNode Convert SqlStatement' > ----------------------------------------- > > Key: CALCITE-3207 > URL: https://issues.apache.org/jira/browse/CALCITE-3207 > Project: Calcite > Issue Type: Bug > Components: core > Reporter: Xurenhe > Priority: Minor > > Hi all > I have a problem when using calcite, which is 'relnode convert sql statement' > example: > // RelToSqlConverterTest.java > @Test public void testLeftJoinRel2Sql() \{ > final RelBuilder builder = relBuilder(); > final RelNode rel = builder > .scan("EMP") > .scan("DEPT") > .join(JoinRelType.LEFT, builder.and( > builder.call(SqlStdOperatorTable.EQUALS, > builder.field(2, 0, "DEPTNO"), > builder.field(2, 1, "DEPTNO") > ), builder.call(SqlStdOperatorTable.LIKE, > builder.field(2, 1, "DNAME"), > builder.literal("ACCOUNTING")))) > .build(); > final String sql = toSql(rel); > final String expectedSql = "SELECT *\n" + > "FROM \"scott\".\"EMP\"\n" + > "LEFT JOIN \"scott\".\"DEPT\" ON \"EMP\".\"DEPTNO\" = > \"DEPT\".\"DEPTNO\"\n" + > "AND \"DEPT\".\"DNAME\" LIKE 'ACCOUNTING'"; > assertThat(sql, isLinux(expectedSql)); > } > this relNode cannot convert sql statement. > I try to debug it, > `org.apache.calcite.rel.rel2sql.SqlImplementor#convertConditionToSqlNode` may > forgot to handle this case, which sqlKind is SqlKind.LIKE. > If it is a bug, I am willing to fix it. > Thanks. > -- This message was sent by Atlassian JIRA (v7.6.14#76016)