From 2afaba319a985d28bb5592e2c195e0c7405b9455 Mon Sep 17 00:00:00 2001 From: discord9 Date: Sat, 24 Oct 2026 18:53:57 +0800 Subject: [PATCH] test(sql): cover persisted TQL views across restart Signed-off-by: discord9 --- .../cases/tql_view_persistence/case.toml | 14 ++++++++++++++ .../cases/tql_view_persistence/setup.sql | 17 +++++++++++++++++ .../cases/tql_view_persistence/verify.sql | 9 +++++++++ 3 files changed, 40 insertions(+) create mode 100644 tests/compatibility/cases/tql_view_persistence/case.toml create mode 100644 tests/compatibility/cases/tql_view_persistence/setup.sql create mode 100644 tests/compatibility/cases/tql_view_persistence/verify.sql diff --git a/tests/compatibility/cases/tql_view_persistence/case.toml b/tests/compatibility/cases/tql_view_persistence/case.toml new file mode 100644 index 00000000000..df085c6ec2a --- /dev/null +++ b/tests/compatibility/cases/tql_view_persistence/case.toml @@ -0,0 +1,14 @@ +name = "tql_view_persistence" +reason = "Verify a TQL CREATE VIEW persisted as a Substrait plan, with its explicit lookback kept in the view definition, still evaluates correctly after a restart on a newer binary." +introduced_by = "feat(sql): support TQL evaluation in persisted views" +topologies = ["standalone", "distributed"] +# setup.sql uses `CREATE VIEW ... AS TQL EVAL (start, end, step, lookback)`, which only +# parses on builds that already carry this feature, so the from side has to stay on the +# 1.4.0 line: today that means a same-candidate restart, and it starts covering real +# release-to-release restarts from the first release that ships the syntax. `*` would +# select older released binaries that cannot parse setup.sql. (The runner compares core +# versions only, so this also admits other 1.4.0 prereleases.) +from_range = [">=v1.4.0-alpha.0"] +to_range = [">=v1.4.0-alpha.0"] +features = ["view", "tql", "substrait", "table", "query"] +owner = "query" diff --git a/tests/compatibility/cases/tql_view_persistence/setup.sql b/tests/compatibility/cases/tql_view_persistence/setup.sql new file mode 100644 index 00000000000..048674fb2b6 --- /dev/null +++ b/tests/compatibility/cases/tql_view_persistence/setup.sql @@ -0,0 +1,17 @@ +-- Fixed-epoch samples: at the 1000s evaluation point, 600.001s is inside the explicit +-- 10m lookback but already outside the default 5m one, and 1000.000s is the point itself. +CREATE TABLE tql_view_source ( + ts TIMESTAMP TIME INDEX, + val DOUBLE, + series STRING PRIMARY KEY +); + +INSERT INTO tql_view_source VALUES + (600001, 41, 'beyond_default_lookback'), + (1000000, 12, 'at_eval'); + +ADMIN FLUSH_TABLE('tql_view_source'); + +CREATE VIEW tql_view_instant AS TQL EVAL (1000, 1000, '1s', '10m') tql_view_source; + +CREATE VIEW tql_view_range AS TQL EVAL (1000, 1000, '1s', '10m') max_over_time(tql_view_source[2s]); diff --git a/tests/compatibility/cases/tql_view_persistence/verify.sql b/tests/compatibility/cases/tql_view_persistence/verify.sql new file mode 100644 index 00000000000..e2c3f5dc788 --- /dev/null +++ b/tests/compatibility/cases/tql_view_persistence/verify.sql @@ -0,0 +1,9 @@ +-- Instant evaluation at 1000s honours the 10m lookback stored in the persisted view +-- plan: 41 is 400s+ old but still selected, 12 sits exactly on the grid point. +SELECT ts, series, val FROM tql_view_instant ORDER BY series; + +SHOW CREATE VIEW tql_view_instant; + +-- The range view binds its own 2s window, so only the sample at the evaluation point +-- survives; the column names come from the plan persisted by the old binary. +SELECT * FROM tql_view_range;