@VisibleForTesting
  static RelNode applyRule(
          RelNode basePlan, RelOptRule relOptRule) {
    final HepProgramBuilder programBuilder = new HepProgramBuilder();
    programBuilder.addRuleInstance(relOptRule);
    final HepPlanner planner = new HepPlanner(
        programBuilder.build());
    planner.setRoot(basePlan);
    return planner.findBestExp();
  }
Method to apply a rule to a query plan.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/views/HiveMaterializedViewUtils.java