### Question:
ExpressionRewriteRuleSet { public Rule<?> aggregationExpressionRewrite() { return new AggregationExpressionRewrite(rewriter); } ExpressionRewriteRuleSet(ExpressionRewriter rewriter); Set<Rule<?>> rules(); Rule<?> projectExpressionRewrite(); Rule<?> aggregationExpressionRewrite(); Rule<?> filterExpressionRewrite(); Rule<?> joinExpressionRewrite(); Rule<?> valuesExpressionRewrite();  }### Answer:
@Test public void testAggregationExpressionRewrite() { ExpressionRewriteRuleSet functionCallRewriter = new ExpressionRewriteRuleSet((expression, context) -> new FunctionCallBuilder(tester().getMetadata()) .setName(QualifiedName.of("count")) .addArgument(VARCHAR, new SymbolReference("y")) .build()); tester().assertThat(functionCallRewriter.aggregationExpressionRewrite()) .on(p -> p.aggregation(a -> a .globalGrouping() .addAggregation( p.symbol("count_1", BigintType.BIGINT), new FunctionCallBuilder(tester().getMetadata()) .setName(QualifiedName.of("count")) .addArgument(VARCHAR, new SymbolReference("x")) .build(), ImmutableList.of(BigintType.BIGINT)) .source( p.values(p.symbol("x"), p.symbol("y"))))) .matches( PlanMatchPattern.aggregation( ImmutableMap.of("count_1", aliases -> new FunctionCallBuilder(tester().getMetadata()) .setName(QualifiedName.of("count")) .addArgument(VARCHAR, new SymbolReference("y")) .build()), values("x", "y"))); }
@Test public void testAggregationExpressionNotRewritten() { FunctionCall nowCall = new FunctionCallBuilder(tester().getMetadata()) .setName(QualifiedName.of("now")) .build(); ExpressionRewriteRuleSet functionCallRewriter = new ExpressionRewriteRuleSet((expression, context) -> nowCall); tester().assertThat(functionCallRewriter.aggregationExpressionRewrite()) .on(p -> p.aggregation(a -> a .globalGrouping() .addAggregation( p.symbol("count_1", DateType.DATE), nowCall, ImmutableList.of()) .source( p.values()))) .doesNotFire(); }