Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/repr/src/refresh_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl RefreshSchedule {

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)]
pub struct RefreshEvery {
pub interval: Duration,
pub interval: Duration, // must be at least 1 ms
pub aligned_to: Timestamp,
}

Expand Down
5 changes: 4 additions & 1 deletion src/sql/src/plan/statement/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2837,7 +2837,7 @@ pub fn plan_create_materialized_view(
}
RefreshOptionValue::AtCreation => {
soft_panic_or_log!("REFRESH AT CREATION should have been purified away");
sql_bail!("INTERNAL ERROR: REFRESH AT CREATION should have been purified away")
bail_internal!("REFRESH AT CREATION should have been purified away")
}
RefreshOptionValue::At(RefreshAtOptionValue { mut time }) => {
transform_ast::transform(scx, &mut time)?; // Desugar the expression
Expand Down Expand Up @@ -2881,6 +2881,9 @@ pub fn plan_create_materialized_view(
if u64::try_from(interval.as_millis()).is_err() {
sql_bail!("REFRESH interval too large");
}
if interval.as_micros() < 1000 {
sql_bail!("REFRESH interval must be at least 1 ms")
}

let mut aligned_to = match aligned_to {
Some(aligned_to) => aligned_to,
Expand Down
5 changes: 5 additions & 0 deletions test/sqllogictest/materialized_views.slt
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,11 @@ CREATE MATERIALIZED VIEW mv_bad WITH (REFRESH EVERY ASSERT NOT NULL x) AS SELECT
query error invalid input syntax for type interval: Overflows maximum days; cannot exceed 2147483647/\-2147483648 days: "213503982001"
CREATE MATERIALIZED VIEW mv_bad WITH (REFRESH EVERY '213503982001' days) AS SELECT * FROM t2;

query error REFRESH interval must be at least 1 ms
CREATE MATERIALIZED VIEW mv_bad
WITH (REFRESH EVERY '999 microseconds')
AS SELECT 1;

# This tests that we don't forget to purify EXPLAIN CREATE MATERIALIZED VIEW
statement ok
EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR CREATE MATERIALIZED VIEW mv_explain WITH (REFRESH EVERY '2 seconds') AS SELECT * FROM t2;
Expand Down
Loading