### Question:
RelToSqlConverter extends SqlImplementor implements ReflectiveVisitor { private SqlCall as( SqlNode e, String alias ) { return SqlStdOperatorTable.AS.createCall( POS, e, new SqlIdentifier( alias, POS ) ); } RelToSqlConverter( SqlDialect dialect ); @Override Result visitChild( int i, RelNode e ); Result visit( RelNode e ); Result visit( Join e ); Result visit( Filter e ); Result visit( Project e ); Result visit( Aggregate e ); Result visit( TableScan e ); Result visit( Union e ); Result visit( Intersect e ); Result visit( Minus e ); Result visit( Calc e ); Result visit( Values e ); Result visit( Sort e ); Result visit( TableModify modify ); Result visit( Match e ); @Override void addSelect( List<SqlNode> selectList, SqlNode node, RelDataType rowType ); abstract SqlIdentifier getPhysicalTableName( List<String> tableName ); abstract SqlIdentifier getPhysicalColumnName( List<String> tableName, String columnName );  }### Answer:
@Test public void testSum0BecomesCoalesce() { final RelBuilder builder = relBuilder(); final RelNode root = builder .scan( "emp" ) .aggregate( builder.groupKey(), builder.aggregateCall( SqlStdOperatorTable.SUM0, builder.field( 3 ) ).as( "s" ) ) .build(); final String expectedMysql = "SELECT COALESCE(SUM(`mgr`), 0) AS `s`\n" + "FROM `scott`.`emp`"; assertThat( toSql( root, DatabaseProduct.MYSQL.getDialect() ), Matchers.isLinux( expectedMysql ) ); final String expectedPostgresql = "SELECT COALESCE(SUM(\"mgr\"), 0) AS \"s\"\n" + "FROM \"scott\".\"emp\""; assertThat( toSql( root, DatabaseProduct.POSTGRESQL.getDialect() ), Matchers.isLinux( expectedPostgresql ) ); }