feat: flush or compact table and region functions (#3363)

* feat: adds Requester to process table flush and compaction request

* feat: admin_fn macros for administration functions

* test: add query result

* feat: impl flush_region, flush_table, compact_region, and flush_region functions

* docs: add Arguments to admin_fn macro

* chore: apply suggestion

Co-authored-by: Zhenchi <zhongzc_arch@outlook.com>

* chore: apply suggestion

Co-authored-by: Zhenchi <zhongzc_arch@outlook.com>

* fix: group_requests_by_peer and adds log

* Update src/common/macro/src/admin_fn.rs

Co-authored-by: Ruihang Xia <waynestxia@gmail.com>

* feat: adds todo for spawan thread

* feat: rebase with main

---------

Co-authored-by: Zhenchi <zhongzc_arch@outlook.com>
Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
dennis zhuang
2024-02-27 16:57:38 +08:00
committed by GitHub
parent dbb1ce1a9b
commit 4b36c285f1
44 changed files with 1590 additions and 389 deletions

View File

@@ -74,6 +74,22 @@ impl<'a> ParserContext<'a> {
Ok(stmts)
}
pub fn parse_table_name(sql: &'a str, dialect: &dyn Dialect) -> Result<ObjectName> {
let mut parser = Parser::new(dialect)
.with_options(ParserOptions::new().with_trailing_commas(true))
.try_with_sql(sql)
.context(SyntaxSnafu)?;
let raw_table_name = parser.parse_object_name().context(error::UnexpectedSnafu {
sql,
expected: "a table name",
actual: parser.peek_token().to_string(),
})?;
let table_name = Self::canonicalize_object_name(raw_table_name);
Ok(table_name)
}
pub fn parse_function(sql: &'a str, dialect: &dyn Dialect) -> Result<Expr> {
let mut parser = Parser::new(dialect)
.with_options(ParserOptions::new().with_trailing_commas(true))
@@ -267,4 +283,39 @@ mod tests {
ConcreteDataType::timestamp_millisecond_datatype(),
);
}
#[test]
pub fn test_parse_table_name() {
let table_name = "a.b.c";
let object_name =
ParserContext::parse_table_name(table_name, &GreptimeDbDialect {}).unwrap();
assert_eq!(object_name.0.len(), 3);
assert_eq!(object_name.to_string(), table_name);
let table_name = "a.b";
let object_name =
ParserContext::parse_table_name(table_name, &GreptimeDbDialect {}).unwrap();
assert_eq!(object_name.0.len(), 2);
assert_eq!(object_name.to_string(), table_name);
let table_name = "Test.\"public-test\"";
let object_name =
ParserContext::parse_table_name(table_name, &GreptimeDbDialect {}).unwrap();
assert_eq!(object_name.0.len(), 2);
assert_eq!(object_name.to_string(), table_name.to_ascii_lowercase());
let table_name = "HelloWorld";
let object_name =
ParserContext::parse_table_name(table_name, &GreptimeDbDialect {}).unwrap();
assert_eq!(object_name.0.len(), 1);
assert_eq!(object_name.to_string(), table_name.to_ascii_lowercase());
}
}