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

          final Union union = call.rel(0);
          final List<RelNode> inputs = union.getInputs();
          assert inputs != null;
          final RelBuilder builder = call.builder();
          int nonEmptyInputs = 0;
          for (RelNode input : inputs) {
            if (!isEmpty(input)) {
              builder.push(input);
              nonEmptyInputs++;
            }
          }
          assert nonEmptyInputs < inputs.size()
                  : "planner promised us at least one Empty child: "
                  + RelOptUtil.toString(union);
          if (nonEmptyInputs == 0) {
            builder.push(union).empty();
          } else {
            builder.union(union.all, nonEmptyInputs);
            builder.convert(union.getRowType(), true);
          }
          call.transformTo(builder.build());
        }
      };
    }
Copy of {@link PruneEmptyRules.UnionEmptyPruneRuleConfig} but this version expects {@link Union}.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRemoveEmptySingleRules.java