/** Creates a project with a dummy column, to protect the parts of the system * that cannot handle a relational expression with no columns. * * @param fieldCount Number of fields in the original relational expression * @param input Trimmed input * @return Dummy project, or null if no dummy is required */ protected TrimResult dummyProject(int fieldCount, RelNode input) { final RelOptCluster cluster = input.getCluster(); final Mapping mapping = Mappings.create(MappingType.INVERSE_SURJECTION, fieldCount, 1); if (input.getRowType().getFieldCount() == 1) { // Input already has one field (and may in fact be a dummy project we // created for the child). We can't do better. return result(input, mapping); } final RexLiteral expr = cluster.getRexBuilder().makeExactLiteral(BigDecimal.ZERO); relBuilder.push(input); relBuilder.project(ImmutableList.<RexNode>of(expr), ImmutableList.of("DUMMY")); return result(relBuilder.build(), mapping); }
/** Creates a project with a dummy column, to protect the parts of the system * that cannot handle a relational expression with no columns. * * @param fieldCount Number of fields in the original relational expression * @param input Trimmed input * @return Dummy project, or null if no dummy is required */ protected TrimResult dummyProject(int fieldCount, RelNode input) { final RelOptCluster cluster = input.getCluster(); final Mapping mapping = Mappings.create(MappingType.INVERSE_SURJECTION, fieldCount, 1); if (input.getRowType().getFieldCount() == 1) { // Input already has one field (and may in fact be a dummy project we // created for the child). We can't do better. return result(input, mapping); } final RexLiteral expr = cluster.getRexBuilder().makeExactLiteral(BigDecimal.ZERO); relBuilder.push(input); relBuilder.project(ImmutableList.<RexNode>of(expr), ImmutableList.of("DUMMY")); return result(relBuilder.build(), mapping); }
/** * Visit method, per {@link org.apache.calcite.util.ReflectiveVisitor}. * * <p>This method is invoked reflectively, so there may not be any apparent * calls to it. The class (or derived classes) may contain overloads of * this method with more specific types for the {@code rel} parameter. * * <p>Returns a pair: the relational expression created, and the mapping * between the original fields and the fields of the newly created * relational expression. * * @param rel Relational expression * @param fieldsUsed Fields needed by the consumer * @return relational expression and mapping */ public TrimResult trimFields( RelNode rel, ImmutableBitSet fieldsUsed, Set<RelDataTypeField> extraFields) { // We don't know how to trim this kind of relational expression, so give // it back intact. Util.discard(fieldsUsed); return result(rel, Mappings.createIdentity(rel.getRowType().getFieldCount())); }
/** * Visit method, per {@link org.apache.calcite.util.ReflectiveVisitor}. * * <p>This method is invoked reflectively, so there may not be any apparent * calls to it. The class (or derived classes) may contain overloads of * this method with more specific types for the {@code rel} parameter. * * <p>Returns a pair: the relational expression created, and the mapping * between the original fields and the fields of the newly created * relational expression. * * @param rel Relational expression * @param fieldsUsed Fields needed by the consumer * @return relational expression and mapping */ public TrimResult trimFields( RelNode rel, ImmutableBitSet fieldsUsed, Set<RelDataTypeField> extraFields) { // We don't know how to trim this kind of relational expression, so give // it back intact. Util.discard(fieldsUsed); return result(rel, Mappings.createIdentity(rel.getRowType().getFieldCount())); }
return result(rel, mapping);
return result(rel, mapping);
return result(newModifier, mapping);
return result(newModifier, mapping);
return result(newTabFun, mapping);
return result(newTabFun, mapping);
return result(relBuilder.build(), Mappings.createIdentity(fieldList.size()));
return result(relBuilder.build(), Mappings.createIdentity(fieldList.size()));
return result(newTableAccessRel, mapping);
return result(newTableAccessRel, mapping);