Search in sources :

Example 41 with OdpsStatementParser

use of com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser in project druid by alibaba.

the class OdpsListTest method test_1.

public void test_1() throws Exception {
    String sql = "list users";
    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("LIST users", output);
}
Also used : OdpsStatementParser(com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Example 42 with OdpsStatementParser

use of com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser in project druid by alibaba.

the class OdpsCreateViewTest method test_create_column_comments.

public void test_create_column_comments() throws Exception {
    String sql = "CREATE view if not exists sale_detail (f1 comment 'aaaa', f2 comment 'bbb') as select * from dual;";
    OdpsStatementParser parser = new OdpsStatementParser(sql);
    SQLStatement stmt = parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toOdpsString(stmt);
    Assert.assertEquals(//
    "CREATE VIEW IF NOT EXISTS sale_detail" + //
    "\n(" + //
    "\n\tf1 COMMENT 'aaaa', " + //
    "\n\tf2 COMMENT 'bbb'" + //
    "\n)" + //
    "\nAS" + //
    "\nSELECT *" + "\nFROM dual", output);
}
Also used : OdpsStatementParser(com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Example 43 with OdpsStatementParser

use of com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser in project druid by alibaba.

the class OdpsCreateViewTest method test_create_if_not_exists.

public void test_create_if_not_exists() throws Exception {
    String sql = "CREATE view if not exists sale_detail as select * from dual;";
    OdpsStatementParser parser = new OdpsStatementParser(sql);
    SQLStatement stmt = parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toOdpsString(stmt);
    Assert.assertEquals(//
    "CREATE VIEW IF NOT EXISTS sale_detail" + //
    "\nAS" + //
    "\nSELECT *" + "\nFROM dual", output);
}
Also used : OdpsStatementParser(com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Example 44 with OdpsStatementParser

use of com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser in project druid by alibaba.

the class OdpsDescTest method test_1.

public void test_1() throws Exception {
    String sql = "desc role admin";
    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("DESC ROLE admin", output);
}
Also used : OdpsStatementParser(com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Aggregations

SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)44 OdpsStatementParser (com.alibaba.druid.sql.dialect.odps.parser.OdpsStatementParser)44 OdpsSchemaStatVisitor (com.alibaba.druid.sql.dialect.odps.visitor.OdpsSchemaStatVisitor)8 SchemaStatVisitor (com.alibaba.druid.sql.visitor.SchemaStatVisitor)6 InputStream (java.io.InputStream)6 InputStreamReader (java.io.InputStreamReader)6 Reader (java.io.Reader)6 Column (com.alibaba.druid.stat.TableStat.Column)2 MySqlSchemaStatVisitor (com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor)1 OdpsOutputVisitor (com.alibaba.druid.sql.dialect.odps.visitor.OdpsOutputVisitor)1 SQLStatementParser (com.alibaba.druid.sql.parser.SQLStatementParser)1 File (java.io.File)1