private static <R extends RelNode> RelOptRule getJoinRightInstance(Class<R> clazz) {
    return new JoinRightEmptyRuleConfig()
            .withOperandSupplier(b0 ->
                    b0.operand(clazz).inputs(
                            b1 -> b1.operand(RelNode.class).anyInputs(),
                            b2 -> b2.operand(Values.class).predicate(Values::isEmpty)
                                    .noInputs()))
            .withDescription("HivePruneEmptyJoin(right)")
            .toRule();
  }
Improved version of Calcite's {@link PruneEmptyRules.JoinLeftEmptyRuleConfig}.
In case of right outer join if the left branch is empty the join operator can be removed
and take the right branch only.

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