From be5364a056a327b471109ea68f727de3be4e2751 Mon Sep 17 00:00:00 2001 From: "Lei, HUANG" <6406592+v0y4g3r@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:38:07 +0800 Subject: [PATCH] chore: support swcs as the short name for strict window compaction (#4517) --- .../function/src/table/flush_compact_table.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/common/function/src/table/flush_compact_table.rs b/src/common/function/src/table/flush_compact_table.rs index 5adfc25108..fe2220b127 100644 --- a/src/common/function/src/table/flush_compact_table.rs +++ b/src/common/function/src/table/flush_compact_table.rs @@ -33,6 +33,8 @@ use crate::handlers::TableMutationHandlerRef; /// Compact type: strict window. const COMPACT_TYPE_STRICT_WINDOW: &str = "strict_window"; +/// Compact type: strict window (short name). +const COMPACT_TYPE_STRICT_WINDOW_SHORT: &str = "swcs"; #[admin_fn( name = FlushTableFunction, @@ -168,8 +170,12 @@ fn parse_compact_params( }) } +/// Parses compaction strategy type. For `strict_window` or `swcs` strict window compaction is chose, +/// otherwise choose regular (TWCS) compaction. fn parse_compact_type(type_str: &str, option: Option<&str>) -> Result { - if type_str.eq_ignore_ascii_case(COMPACT_TYPE_STRICT_WINDOW) { + if type_str.eq_ignore_ascii_case(COMPACT_TYPE_STRICT_WINDOW) + | type_str.eq_ignore_ascii_case(COMPACT_TYPE_STRICT_WINDOW_SHORT) + { let window_seconds = option .map(|v| { i64::from_str(v).map_err(|_| { @@ -350,6 +356,17 @@ mod tests { compact_options: Options::Regular(Default::default()), }, ), + ( + &["table", "swcs", "120"], + CompactTableRequest { + catalog_name: DEFAULT_CATALOG_NAME.to_string(), + schema_name: DEFAULT_SCHEMA_NAME.to_string(), + table_name: "table".to_string(), + compact_options: Options::StrictWindow(StrictWindow { + window_seconds: 120, + }), + }, + ), ]); assert!(parse_compact_params(