public static String formatSql(final AstNode root) {
    final StringBuilder builder = new StringBuilder();
    new Formatter(builder).process(root, 0);
    return StringUtils.stripEnd(builder.toString(), "\n");
  }
@Test
  public void shouldFormatCsasPartitionBy() {
    final String statementString = "CREATE STREAM S AS SELECT * FROM ADDRESS PARTITION BY ADDRESS;";
    final Statement statement = parseSingle(statementString);

    final String result = SqlFormatter.formatSql(statement);

    assertThat(result, is("CREATE STREAM S AS SELECT *\n"
        + "FROM ADDRESS ADDRESS\n"
        + "PARTITION BY ADDRESS\n"
        + "EMIT CHANGES"
    ));
  }