public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
final BlockBuilder builder = new BlockBuilder();
final Result result = implementor.visitChild(
this, 0, (EnumerableRel) getChild(), pref);
Expression childExp =
builder.append(
"child", result.block);
final ParameterExpression collectionParameter =
Expressions.parameter(Collection.class,
builder.newName("collection"));
final Expression expression = table.getExpression(ModifiableTable.class);
assert expression != null; // TODO: user error in validator
assert ModifiableTable.class.isAssignableFrom(
Types.toClass(expression.getType())) : expression.getType();
builder.add(
Expressions.declare(
Modifier.FINAL,
collectionParameter,
Expressions.call(
expression,
BuiltinMethod.MODIFIABLE_TABLE_GET_MODIFIABLE_COLLECTION
.method)));
final Expression countParameter =
builder.append(
"count",
Expressions.call(collectionParameter, "size"),
false);
Expression convertedChildExp;
if (!getChild().getRowType().equals(getRowType())) {
final JavaTypeFactory typeFactory =
(JavaTypeFactory) getCluster().getTypeFactory();
PhysType physType =
PhysTypeImpl.of(