@Override
  protected RelNode trim(RelOptRuleCall call, RelNode node) {
    RelNode optimized = new HiveCardinalityPreservingJoinOptimization().trim(call.builder(), node);
    if (optimized == node) {
      return node;
    }

    RelNode chosen = choosePlan(node, optimized);
    new JoinAlgorithmSetter().visit(chosen);
    return chosen;
  }
Rule to trigger {@link HiveCardinalityPreservingJoinOptimization} on top of the plan.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveCardinalityPreservingJoinRule.java