final RelBuilder builder = RelBuilder.create(config().build());
RelNode root =
builder.scan("EMP")
.as("e")
.scan("EMP")
.as("m")
.scan("DEPT")
.join(JoinRelType.INNER)
.join(JoinRelType.INNER)
.filter(
builder.equals(builder.field("e", "DEPTNO"),
builder.field("DEPT", "DEPTNO")),
builder.equals(builder.field("m", "EMPNO"),
builder.field("e", "MGR")))
.build();
final String expected = ""
+ "LogicalFilter(condition=[AND(=($7, $16), =($8, $3))])\n"
+ " LogicalJoin(condition=[true], joinType=[inner])\n"
+ " LogicalTableScan(table=[[scott, EMP]])\n"
+ " LogicalJoin(condition=[true], joinType=[inner])\n"
+ " LogicalTableScan(table=[[scott, EMP]])\n"
+ " LogicalTableScan(table=[[scott, DEPT]])\n";
assertThat(str(root), is(expected));
上面的代码来自 RelBuilderTest.java 。为什么calcite会生成LogicalJoin(condition=[true], joinType=[inner])
Node?当我使用RelToSqlConverter
将 RelNode 转换为 SQL 时,遇到关于filter 'condition=[true]'
ava.lang.AssertionError: Internal error: While invoking method 'public org.apache.calcite.rel.rel2sql.SqlImplementor$Result org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(org.apache.calcite.rel.core.Filter)
at org.apache.calcite.util.Util.newInternal(Util.java:792)
at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:535)
at org.apache.calcite.rel.rel2sql.RelToSqlConverter.dispatch(RelToSqlConverter.java:80
为什么会这样?