From 16a2f239379c831ee232b70485058d255adc1074 Mon Sep 17 00:00:00 2001 From: Micah Wylde Date: Thu, 12 Dec 2024 11:14:23 -0800 Subject: [PATCH] Plan hop(x, x) to tumble(x) --- crates/arroyo-planner/src/lib.rs | 7 ++++++- crates/arroyo-planner/src/test/queries/hop_to_tumble.sql | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 crates/arroyo-planner/src/test/queries/hop_to_tumble.sql diff --git a/crates/arroyo-planner/src/lib.rs b/crates/arroyo-planner/src/lib.rs index 980cd2880..a9972e1af 100644 --- a/crates/arroyo-planner/src/lib.rs +++ b/crates/arroyo-planner/src/lib.rs @@ -588,7 +588,12 @@ fn find_window(expression: &Expr) -> Result> { slide ); } - Ok(Some(WindowType::Sliding { width, slide })) + if slide == width { + // a hop window with slide == width is a tumble window + Ok(Some(WindowType::Tumbling { width })) + } else { + Ok(Some(WindowType::Sliding { width, slide })) + } } "tumble" => { if args.len() != 1 { diff --git a/crates/arroyo-planner/src/test/queries/hop_to_tumble.sql b/crates/arroyo-planner/src/test/queries/hop_to_tumble.sql new file mode 100644 index 000000000..fd94cea58 --- /dev/null +++ b/crates/arroyo-planner/src/test/queries/hop_to_tumble.sql @@ -0,0 +1,7 @@ +create table impulse with ( + connector = 'impulse', + event_rate = '10' +); + +select count(*) from impulse +group by hop(interval '10 seconds', interval '10 seconds'); \ No newline at end of file