Frameworks.withPlanner(new Frameworks.PlannerAction<RelNode>() {
public RelNode apply(RelOptCluster cluster,
RelOptSchema relOptSchema,
SchemaPlus rootSchema) {
final RelDataTypeFactory typeFactory = cluster.getTypeFactory();
final Table table = new AbstractTable() {
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
final RelDataType stringType =
typeFactory.createJavaType(String.class);
final RelDataType integerType =
typeFactory.createJavaType(Integer.class);
return typeFactory.builder()
.add("s", stringType)
.add("i", integerType)
.build();
}
};
// "SELECT * FROM myTable"
final RelOptAbstractTable relOptTable = new RelOptAbstractTable(
relOptSchema,
"myTable",
table.getRowType(typeFactory)) {
};
final JavaRules.EnumerableTableAccessRel tableRel =
new JavaRules.EnumerableTableAccessRel(
cluster, cluster.traitSetOf(EnumerableConvention.INSTANCE),
relOptTable, Object[].class);