use of com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser in project druid by alibaba.
the class OdpsGrantTest method test_2.
public void test_2() throws Exception {
String sql = "grant super Write to user aliyun$DXP_xxxxx@aliyun.com";
OdpsStatementParser parser = new OdpsStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toOdpsString(stmt);
// System.out.println(output);
Assert.assertEquals("GRANT SUPER WRITE TO USER aliyun$DXP_xxxxx@aliyun.com", output);
}
use of com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser in project druid by alibaba.
the class OdpsGrantTest method test_1.
public void test_1() throws Exception {
String sql = "grant role_project_admin to aliyun$DXP_xxxxx@aliyun.com";
OdpsStatementParser parser = new OdpsStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toOdpsString(stmt);
// System.out.println(output);
Assert.assertEquals("GRANT role_project_admin TO aliyun$DXP_xxxxx@aliyun.com", output);
}
use of com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser in project druid by alibaba.
the class OdpsGrantTest method test_3.
public void test_3() throws Exception {
String sql = "grant label 2 on table adl_register_baseline_sdt(c1, c2) to user aliyun$DXP_xxxxx@aliyun.com with exp 5";
OdpsStatementParser parser = new OdpsStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toOdpsString(stmt);
// System.out.println(output);
Assert.assertEquals("GRANT LABEL 2 ON TABLE adl_register_baseline_sdt(c1, c2) TO USER aliyun$DXP_xxxxx@aliyun.com WITH EXP 5", output);
}
use of com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser in project druid by alibaba.
the class OdpsGrantTest method test_0.
public void test_0() throws Exception {
String sql = "grant update, Select on table adl_register_baseline_sdt to user DXP_71074213@aliyun.com";
OdpsStatementParser parser = new OdpsStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toOdpsString(stmt);
// System.out.println(output);
Assert.assertEquals("GRANT UPDATE, SELECT ON TABLE adl_register_baseline_sdt TO USER DXP_71074213@aliyun.com", output);
}
use of com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser in project druid by alibaba.
the class OdpsListResourcesTest method exec_test.
public void exec_test(String resource) throws Exception {
// System.out.println(resource);
InputStream is = null;
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
Reader reader = new InputStreamReader(is, "UTF-8");
String input = Utils.read(reader);
JdbcUtils.close(reader);
String[] items = input.split("---------------------------");
String sql = items[0].trim();
String expect = items[1].trim();
OdpsStatementParser parser = new OdpsStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
Assert.assertEquals(1, statementList.size());
SchemaStatVisitor visitor = new OdpsSchemaStatVisitor();
stmt.accept(visitor);
// System.out.println(sql);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
//
// System.out.println();
// System.out.println("---------------------------");
// System.out.println(SQLUtils.toOdpsString(stmt));
}
Aggregations