@Override
    public PruneEmptyRule toRule() {
      return new PruneEmptyRule(this) {
        @Override public void onMatch(RelOptRuleCall call) {
          if (Bug.CALCITE_5294_FIXED) {
            throw new IllegalStateException(
                    "Class JoinRightEmptyRuleConfig is redundant after fix is merged into Calcite");
          }

          final Join join = call.rel(0);
          final RelNode left = call.rel(1);
          final RelBuilder relBuilder = call.builder();
          if (join.getJoinType().generatesNullsOnRight()) {
            // If "dept" is empty, "select * from emp left join dept" will have
            // the same number of rows as "emp", and null values for the
            // columns from "dept". The right side of the join can be removed.
            call.transformTo(padWithNulls(relBuilder, left, join.getRowType(), false));
            return;
          }
          if (join.getJoinType() == JoinRelType.ANTI) {
            // In case of anti join: Join(X, Empty, ANTI) becomes X
            call.transformTo(join.getLeft());
            return;
          }
          call.transformTo(relBuilder.push(join).empty().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