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);
}
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);
}
Aggregations