diff --git a/src/sql/src/parsers/create_parser.rs b/src/sql/src/parsers/create_parser.rs index a257f029e35..046f66c2b7e 100644 --- a/src/sql/src/parsers/create_parser.rs +++ b/src/sql/src/parsers/create_parser.rs @@ -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] diff --git a/src/table/src/requests.rs b/src/table/src/requests.rs index b4a7d5e052b..0e00236a760 100644 --- a/src/table/src/requests.rs +++ b/src/table/src/requests.rs @@ -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> = Lazy::new(|| { let mut set = HashSet::new(); @@ -120,6 +123,7 @@ static VALID_DB_OPT_KEYS: Lazy> = 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")); }