@Override
  public boolean matches(RelOptRuleCall call) {
    final Aggregate aggregate = call.rel(0);
    // Rule cannot be applied if there are GroupingId because it will change the
    // value as the position will be changed.
    for (AggregateCall aggCall : aggregate.getAggCallList()) {
      if (aggCall.getAggregation().equals(HiveGroupingID.INSTANCE)) {
        return false;
      }
    }
    return super.matches(call);
  }
Planner rule that recognizes a {@link HiveAggregate}
on top of a {@link HiveProject} and if possible
aggregate through the project or removes the project.

<p>This is only possible when the grouping expressions and arguments to
the aggregate functions are field references (i.e. not expressions).

<p>In some cases, this rule has the effect of trimming: the aggregate will
use fewer columns than the project did.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveAggregateProjectMergeRule.java