mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-23 08:20:36 +00:00
feat: support desc [table] <table_name> (#1944)
* feat: support desc [table] Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * refine style Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
@@ -261,10 +261,8 @@ impl<'a> ParserContext<'a> {
|
||||
fn parse_describe(&mut self) -> Result<Statement> {
|
||||
if self.matches_keyword(Keyword::TABLE) {
|
||||
let _ = self.parser.next_token();
|
||||
self.parse_describe_table()
|
||||
} else {
|
||||
self.unsupported(self.peek_token_as_string())
|
||||
}
|
||||
self.parse_describe_table()
|
||||
}
|
||||
|
||||
fn parse_describe_table(&mut self) -> Result<Statement> {
|
||||
@@ -677,4 +675,20 @@ mod tests {
|
||||
ParserContext::parse_function("current_timestamp()", &GreptimeDbDialect {}).unwrap();
|
||||
assert!(matches!(expr, Expr::Function(_)));
|
||||
}
|
||||
|
||||
fn assert_describe_table(sql: &str) {
|
||||
let stmt = ParserContext::create_with_dialect(sql, &GreptimeDbDialect {})
|
||||
.unwrap()
|
||||
.pop()
|
||||
.unwrap();
|
||||
assert!(matches!(stmt, Statement::DescribeTable(_)))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_describe_table() {
|
||||
assert_describe_table("desc table t;");
|
||||
assert_describe_table("describe table t;");
|
||||
assert_describe_table("desc t;");
|
||||
assert_describe_table("describe t;");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user