@Test
public void rename_to_invalid_expression() {

  SemanticCheckException exception =
      assertThrows(
          SemanticCheckException.class,
          () ->
              analyze(
                  AstDSL.rename(
                      AstDSL.agg(
                          AstDSL.relation("schema"),
                          AstDSL.exprList(
                              AstDSL.alias("avg(integer_value)", AstDSL.aggregate("avg", field(
                                  "integer_value")))),
                          Collections.emptyList(),
                          ImmutableList.of(),
                          AstDSL.defaultStatsArgs()),
                      AstDSL.map(
                          AstDSL.aggregate("avg", field("integer_value")),
                          AstDSL.aggregate("avg", field("integer_value"))))));
  assertEquals(
      "the target expected to be field, but is avg(Field(field=integer_value, fieldArgs=[]))",
      exception.getMessage());
}