use of com.alibaba.druid.sql.dialect.odps.visitor.OdpsOutputVisitor in project druid by alibaba.
the class Bug_for_qianbi method test_for_issue.
public void test_for_issue() throws Exception {
String sql = "insert into table lol select detail(sellerid,id) as count1,sum(sellerid) as sum1 from ctu_trade_paid_done.time('natural','1d','1h') " + "where match(auctionTitle,\"男鞋\\n中石化&加油卡\\n中石化&充值卡\\n中石化&冲值卡\\n中石化&代冲\\n中石化&代充\\n中国石化&加油卡\\n中国石化&充值卡\\n中国石化&冲值卡\\n中国石化&代冲\\n中国石化&代充\",\"\\n\")";
String expected = "INSERT INTO TABLE lol\n" + "SELECT detail(sellerid, id) AS count1, sum(sellerid) AS sum1\n" + "FROM ctu_trade_paid_done:time('natural', '1d', '1h')\n" + "WHERE match(auctionTitle, '男鞋\\n中石化&加油卡\\n中石化&充值卡\\n中石化&冲值卡\\n中石化&代冲\\n中石化&代充\\n中国石化&加油卡\\n中国石化&充值卡\\n中国石化&冲值卡\\n中国石化&代冲\\n中国石化&代充', '\\n');\n";
StringBuilder out = new StringBuilder();
OdpsOutputVisitor visitor = new OdpsOutputVisitor(out);
OdpsStatementParser parser = new OdpsStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
for (SQLStatement statement : statementList) {
statement.accept(visitor);
visitor.print(";");
visitor.println();
}
// System.out.println(out.toString());
Assert.assertEquals(expected, out.toString());
}
Aggregations