@Override
  public void onMatch(final RelOptRuleCall call) {
    CommonTableExpressionRegistry r = call.getPlanner().getContext().unwrap(CommonTableExpressionRegistry.class);
    r.add(call.rel(0));
  }
Rule for saving relational expressions that appear more than once in a query tree to the planner context.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/CommonRelSubExprRegisterRule.java