feat: add ingest_rows_rate_limit database option

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
This commit is contained in:
Lei, HUANG
2026-08-18 17:02:14 +08:00
parent a8924bb95c
commit 782c495587
2 changed files with 18 additions and 0 deletions
+12
View File
@@ -1507,6 +1507,18 @@ mod tests {
}
_ => unreachable!(),
}
let sql = "CREATE DATABASE prometheus with ('ingest_rows_rate_limit'='1000');";
let result =
ParserContext::create_with_dialect(sql, &GreptimeDbDialect {}, ParseOptions::default());
let stmts = result.unwrap();
match &stmts[0] {
Statement::CreateDatabase(c) => {
assert_eq!(c.name.to_string(), "prometheus");
assert_eq!(c.options.get("ingest_rows_rate_limit").unwrap(), "1000");
}
_ => unreachable!(),
}
}
#[test]
+6
View File
@@ -101,6 +101,9 @@ pub const DDL_WAIT: &str = "wait";
pub const VALID_DDL_OPTION_KEYS: [&str; 2] = [DDL_TIMEOUT, DDL_WAIT];
/// The key of ingest rows rate limit option (rows per second, cluster-wide) in database options.
pub const INGEST_ROWS_RATE_LIMIT_KEY: &str = "ingest_rows_rate_limit";
// Valid option keys when creating a db.
static VALID_DB_OPT_KEYS: Lazy<HashSet<&str>> = Lazy::new(|| {
let mut set = HashSet::new();
@@ -120,6 +123,7 @@ static VALID_DB_OPT_KEYS: Lazy<HashSet<&str>> = Lazy::new(|| {
set.insert(TWCS_TRIGGER_FILE_NUM);
set.insert(TWCS_MAX_OUTPUT_FILE_SIZE);
set.insert(SST_FORMAT_KEY);
set.insert(INGEST_ROWS_RATE_LIMIT_KEY);
set
});
@@ -539,6 +543,8 @@ mod tests {
MEMTABLE_BULK_ENCODE_BYTES_THRESHOLD
));
assert!(validate_database_option(MEMTABLE_BULK_MAX_MERGE_GROUPS));
assert!(validate_database_option(INGEST_ROWS_RATE_LIMIT_KEY));
assert!(validate_database_option("ingest_rows_rate_limit"));
assert!(!validate_database_option("foo"));
}