/** * Trims unused fields from a relational expression. * * <p>We presume that all fields of the relational expression are wanted by * its consumer, so only trim fields that are not used within the tree. * * @param root Root node of relational expression * @return Trimmed relational expression */ public RelNode trim(RelNode root) { final int fieldCount = root.getRowType().getFieldCount(); final ImmutableBitSet fieldsUsed = ImmutableBitSet.range(fieldCount); final Set<RelDataTypeField> extraFields = Collections.emptySet(); final TrimResult trimResult = dispatchTrimFields(root, fieldsUsed, extraFields); if (!trimResult.right.isIdentity()) { throw new IllegalArgumentException(); } if (SqlToRelConverter.SQL2REL_LOGGER.isDebugEnabled()) { SqlToRelConverter.SQL2REL_LOGGER.debug( RelOptUtil.dumpPlan("Plan after trimming unused fields", trimResult.left, SqlExplainFormat.TEXT, SqlExplainLevel.EXPPLAN_ATTRIBUTES)); } return trimResult.left; }
/** * Trims unused fields from a relational expression. * * <p>We presume that all fields of the relational expression are wanted by * its consumer, so only trim fields that are not used within the tree. * * @param root Root node of relational expression * @return Trimmed relational expression */ public RelNode trim(RelNode root) { final int fieldCount = root.getRowType().getFieldCount(); final ImmutableBitSet fieldsUsed = ImmutableBitSet.range(fieldCount); final Set<RelDataTypeField> extraFields = Collections.emptySet(); final TrimResult trimResult = dispatchTrimFields(root, fieldsUsed, extraFields); if (!trimResult.right.isIdentity()) { throw new IllegalArgumentException(); } if (SqlToRelConverter.SQL2REL_LOGGER.isDebugEnabled()) { SqlToRelConverter.SQL2REL_LOGGER.debug( RelOptUtil.dumpPlan("Plan after trimming unused fields", trimResult.left, SqlExplainFormat.TEXT, SqlExplainLevel.EXPPLAN_ATTRIBUTES)); } return trimResult.left; }
return dispatchTrimFields(input, fieldsUsedBuilder.build(), extraFields);
return dispatchTrimFields(input, fieldsUsedBuilder.build(), extraFields);