Search in sources :

Example 1 with DescTableStatement

use of com.alibaba.cobar.parser.ast.stmt.ddl.DescTableStatement in project cobar by alibaba.

the class MySQLDALParser method desc.

public DescTableStatement desc() throws SQLSyntaxErrorException {
    match(KW_DESC, KW_DESCRIBE);
    Identifier table = identifier();
    return new DescTableStatement(table);
}
Also used : DescTableStatement(com.alibaba.cobar.parser.ast.stmt.ddl.DescTableStatement) Identifier(com.alibaba.cobar.parser.ast.expression.primary.Identifier)

Example 2 with DescTableStatement

use of com.alibaba.cobar.parser.ast.stmt.ddl.DescTableStatement in project cobar by alibaba.

the class MySQLDALParserTest method testdesc.

public void testdesc() throws Exception {
    String sql = "desc tb1";
    MySQLLexer lexer = new MySQLLexer(sql);
    MySQLDALParser parser = new MySQLDALParser(lexer, new MySQLExprParser(lexer));
    SQLStatement desc = (DescTableStatement) parser.desc();
    parser.match(MySQLToken.EOF);
    String output = output2MySQL(desc, sql);
    Assert.assertEquals("DESC tb1", output);
    sql = "desc db.tb1";
    lexer = new MySQLLexer(sql);
    parser = new MySQLDALParser(lexer, new MySQLExprParser(lexer));
    desc = (DescTableStatement) parser.desc();
    parser.match(MySQLToken.EOF);
    output = output2MySQL(desc, sql);
    Assert.assertEquals("DESC db.tb1", output);
    sql = "describe db.tb1";
    lexer = new MySQLLexer(sql);
    parser = new MySQLDALParser(lexer, new MySQLExprParser(lexer));
    desc = (DescTableStatement) parser.desc();
    parser.match(MySQLToken.EOF);
    output = output2MySQL(desc, sql);
    Assert.assertEquals("DESC db.tb1", output);
}
Also used : MySQLLexer(com.alibaba.cobar.parser.recognizer.mysql.lexer.MySQLLexer) DescTableStatement(com.alibaba.cobar.parser.ast.stmt.ddl.DescTableStatement) SQLStatement(com.alibaba.cobar.parser.ast.stmt.SQLStatement)

Aggregations

DescTableStatement (com.alibaba.cobar.parser.ast.stmt.ddl.DescTableStatement)2 Identifier (com.alibaba.cobar.parser.ast.expression.primary.Identifier)1 SQLStatement (com.alibaba.cobar.parser.ast.stmt.SQLStatement)1 MySQLLexer (com.alibaba.cobar.parser.recognizer.mysql.lexer.MySQLLexer)1