core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java
/** 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
   */
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
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
private 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) {
      return new TrimResult(input, mapping);
    }
    final RexLiteral expr =
        cluster.getRexBuilder().makeExactLiteral(BigDecimal.ZERO);
    final RelNode newProject = projectFactory.createProject(input,
        ImmutableList.<RexNode>of(expr), ImmutableList.of("DUMMY"));
    return new TrimResult(newProject, mapping);
  }
private 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 ) { return new TrimResult ( input , mapping ) ; } final RexLiteral expr = cluster . getRexBuilder ( ) . makeExactLiteral ( BigDecimal . ZERO ) ; final RelNode newProject = projectFactory . createProject ( input , ImmutableList . < RexNode > of ( expr ) , ImmutableList . of ( "DUMMY" ) ) ; return new TrimResult ( newProject , mapping ) ; }
Creates a project with a dummy column, to protect the parts of the system
 that cannot handle a relational expression with no columns.
Creates a project with a dummy column to protect the parts of the system that cannot handle a relational expression with no columns .
// Input already has one field (and may in fact be a dummy project we // created for the child). We can't do better.