/** * Walks over a tree of relational expressions, replacing each * {@link org.apache.calcite.rel.RelNode} with a 'slimmed down' relational * expression that projects * only the columns required by its consumer. * * @param root Root of relational expression tree * @return Trimmed relational expression */ protected RelRoot trimUnusedFields(RelRoot root) { final SqlToRelConverter.Config config = SqlToRelConverter.configBuilder() .withTrimUnusedFields(shouldTrim(root.rel)) .withExpand(THREAD_EXPAND.get()) .build(); final SqlToRelConverter converter = getSqlToRelConverter(getSqlValidator(), catalogReader, config); final boolean ordered = !root.collation.getFieldCollations().isEmpty(); final boolean dml = SqlKind.DML.contains(root.kind); return root.withRel(converter.trimUnusedFields(dml || ordered, root.rel)); }
/** * Walks over a tree of relational expressions, replacing each * {@link org.apache.calcite.rel.RelNode} with a 'slimmed down' relational * expression that projects * only the columns required by its consumer. * * @param root Root of relational expression tree * @return Trimmed relational expression */ protected RelRoot trimUnusedFields(RelRoot root) { final SqlToRelConverter.Config config = SqlToRelConverter.configBuilder() .withTrimUnusedFields(shouldTrim(root.rel)) .withExpand(THREAD_EXPAND.get()) .build(); final SqlToRelConverter converter = getSqlToRelConverter(getSqlValidator(), catalogReader, config); final boolean ordered = !root.collation.getFieldCollations().isEmpty(); final boolean dml = SqlKind.DML.contains(root.kind); return root.withRel(converter.trimUnusedFields(dml || ordered, root.rel)); }
root = root.withRel(converter.trimUnusedFields(true, root.rel));
root = root.withRel(converter.trimUnusedFields(true, root.rel));
converter = t.createSqlToRelConverter(validator, catalogReader, typeFactory, SqlToRelConverter.configBuilder().withTrimUnusedFields(true).build()); root = root.withRel(converter.trimUnusedFields(false, root.rel)); String planAfter = NL + RelOptUtil.toString(root.rel); diffRepos.assertEquals("planAfter", "${planAfter}", planAfter);
converter = t.createSqlToRelConverter(validator, catalogReader, typeFactory, SqlToRelConverter.configBuilder().withTrimUnusedFields(true).build()); root = root.withRel(converter.trimUnusedFields(false, root.rel)); String planAfter = NL + RelOptUtil.toString(root.rel); diffRepos.assertEquals("planAfter", "${planAfter}", planAfter);