private static RelNode padWithNulls(RelBuilder builder, RelNode input, RelDataType resultType,
      boolean leftPadding) {
    int padding = resultType.getFieldCount() - input.getRowType().getFieldCount();
    List<RexNode> nullLiterals = Collections.nCopies(padding, builder.literal(null));
    builder.push(input);
    if (leftPadding) {
      builder.project(concat(nullLiterals, builder.fields()));
    } else {
      builder.project(concat(builder.fields(), nullLiterals));
    }
    return builder.convert(resultType, true).build();
  }
Improved version of Calcite's {@link PruneEmptyRules.JoinRightEmptyRuleConfig}.
In case of left outer join if the right branch is empty the join operator can be removed
and take the left branch only.

select * from emp right join (select * from dept where 1=0)
to
select emp.*, null as dept.col0 ... null as dept.coln from emp
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRemoveEmptySingleRules.java