use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class Issue_685 method test_for_issue.
public void test_for_issue() throws Exception {
OracleStatementParser parser = new OracleStatementParser("select upper(*) from aa order by now()");
SQLStatement st = parser.parseStatement();
st.toString();
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class MySqlPerfMain_visitor method perfMySql.
static long perfMySql(String sql) {
long startYGC = TestUtils.getYoungGC();
long startYGCTime = TestUtils.getYoungGCTime();
long startFGC = TestUtils.getFullGC();
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
long startMillis = System.currentTimeMillis();
for (int i = 0; i < 1000 * 1000 * 1; ++i) {
execMySql(statementList);
}
long millis = System.currentTimeMillis() - startMillis;
long ygc = TestUtils.getYoungGC() - startYGC;
long ygct = TestUtils.getYoungGCTime() - startYGCTime;
long fgc = TestUtils.getFullGC() - startFGC;
System.out.println("MySql\t" + millis + ", ygc " + ygc + ", ygct " + ygct + ", fgc " + fgc);
return millis;
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class MySqlPerfTest method execMySql.
private String execMySql(String sql) {
StringBuilder out = new StringBuilder();
MySqlOutputVisitor visitor = new MySqlOutputVisitor(out);
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
// }
return out.toString();
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class CreateDatabaseTest method test_0.
public void test_0() throws Exception {
String sql = "CREATE DATABASE mydb";
List<SQLStatement> stmtList = SQLUtils.toStatementList(sql, null);
SQLStatement stmt = stmtList.get(0);
Assert.assertEquals("CREATE DATABASE mydb", SQLUtils.toSQLString(stmt, null));
}
use of com.alibaba.druid.sql.ast.SQLStatement in project druid by alibaba.
the class OverTest method test_over.
public void test_over() throws Exception {
String sql = //
"SELECT SalesOrderID, ProductID, OrderQty" + //
" ,SUM(OrderQty) OVER(PARTITION BY SalesOrderID) AS 'Total'" + //
" ,AVG(OrderQty) OVER(PARTITION BY SalesOrderID) AS 'Avg'" + //
" ,COUNT(OrderQty) OVER(PARTITION BY SalesOrderID) AS 'Count'" + //
" ,MIN(OrderQty) OVER(PARTITION BY SalesOrderID) AS 'Min'" + //
" ,MAX(OrderQty) OVER(PARTITION BY SalesOrderID) AS 'Max' " + //
"FROM Sales.SalesOrderDetail " + "WHERE SalesOrderID IN(43659,43664);";
SQLStatementParser parser = new SQLStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
Assert.assertEquals(1, statementList.size());
SchemaStatVisitor visitor = new SchemaStatVisitor();
statemen.accept(visitor);
System.out.println("Tables : " + visitor.getTables());
System.out.println("fields : " + visitor.getColumns());
System.out.println("coditions : " + visitor.getConditions());
Assert.assertEquals(3, visitor.getColumns().size());
Assert.assertEquals(1, visitor.getTables().size());
}
Aggregations