use of com.alibaba.druid.support.calcite.CalciteMySqlNodeVisitor in project druid by alibaba.
the class MySqlParameterizedOutputVisitorTest_47_hints method test_headHint_2.
public void test_headHint_2() throws Exception {
String sql = "/*TDDL : construct()*/ select /*TDDL : add_ms(sort=t.pk, asc=true) add_agg(agg=\"SUM\", group=\"pk\", column=\"c\") add_pj(c=\"c\") add_ts(c, true) */ pk, count(*) c from tb1 where id in(1,2,3,4) group by pk order by pk";
MySqlStatementParser parser = new MySqlStatementParser(sql, SQLParserFeature.TDDLHint);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
CalciteMySqlNodeVisitor visitor = new CalciteMySqlNodeVisitor();
statemen.accept(visitor);
SqlNode sqlNode = visitor.getSqlNode();
System.out.println(sqlNode);
SqlNodeList hints = ((TDDLSqlSelect) sqlNode).getHints();
Assert.assertEquals(hints.size(), 1);
Assert.assertEquals(((SqlNodeList) hints.get(0)).size(), 4);
SqlNodeList headHints = ((TDDLSqlSelect) sqlNode).getHeadHints();
Assert.assertEquals(headHints.size(), 1);
Assert.assertEquals(((SqlNodeList) headHints.get(0)).size(), 1);
}
Aggregations