Add real-time aggregation test to update test

This patch adds a continuous aggregate with real-time aggregation
enabled to the update test suite since we rebuild view definition
for real time aggregation during extension update.
The continuous aggregate is in its own schema because all view
definitions in the public schema are dumped and those view
definitions will change between versions.
This commit is contained in:
Sven Klemm 2020-05-16 01:04:14 +02:00 committed by Sven Klemm
parent 0ea509cc48
commit dab50aef19
6 changed files with 72 additions and 5 deletions

View File

@ -0,0 +1,16 @@
-- This file and its contents are licensed under the Apache License 2.0.
-- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.
\ir post.continuous_aggs.sql
\d cagg.*
SELECT * FROM cagg.realtime_mat ORDER BY bucket, location;
REFRESH MATERIALIZED VIEW cagg.realtime_mat;
SELECT * FROM cagg.realtime_mat ORDER BY bucket, location;
SELECT view_name, refresh_lag, refresh_interval, max_interval_per_job, ignore_invalidation_older_than, materialized_only, materialization_hypertable FROM timescaledb_information.continuous_aggregates ORDER BY view_name::text;

View File

@ -4,5 +4,5 @@
\ir post.v2.sql
\ir post.compression.sql
\ir post.continuous_aggs.sql
\ir post.continuous_aggs.v2.sql

View File

@ -5,5 +5,5 @@
\ir post.v2.sql
\ir catalog_missing_columns.sql
\ir post.compression.sql
\ir post.continuous_aggs.sql
\ir post.continuous_aggs.v2.sql

View File

@ -5,4 +5,4 @@
\ir post.v2.sql
\ir catalog_missing_columns.sql
\ir post.compression.sql
\ir post.continuous_aggs.sql
\ir post.continuous_aggs.v2.sql

View File

@ -3,5 +3,5 @@
-- LICENSE-APACHE for a copy of the license.
\ir post.v2.sql
\ir post.continuous_aggs.sql
\ir post.continuous_aggs.v2.sql

View File

@ -70,4 +70,55 @@ AS
GROUP BY bucket, location
HAVING min(location) >= 'NYC' and avg(temperature) > 2;
REFRESH MATERIALIZED VIEW mat_before;
REFRESH MATERIALIZED VIEW mat_before;
-- we create separate schema for realtime agg since we dump all view definitions in public schema
-- but realtime agg view definition is not stable across versions
CREATE SCHEMA cagg;
CREATE VIEW cagg.realtime_mat
WITH ( timescaledb.continuous, timescaledb.materialized_only=false, timescaledb.refresh_lag='-30 day', timescaledb.max_interval_per_job ='1000 day')
AS
SELECT time_bucket('1week', timec) as bucket,
location,
min(allnull) as min_allnull,
max(temperature) as max_temp,
sum(temperature)+sum(humidity) as agg_sum_expr,
avg(humidity),
stddev(humidity),
bit_and(bit_int),
bit_or(bit_int),
bool_and(good_life),
every(temperature > 0),
bool_or(good_life),
count(*) as count_rows,
count(temperature) as count_temp,
count(allnull) as count_zero,
corr(temperature, humidity),
covar_pop(temperature, humidity),
covar_samp(temperature, humidity),
regr_avgx(temperature, humidity),
regr_avgy(temperature, humidity),
regr_count(temperature, humidity),
regr_intercept(temperature, humidity),
regr_r2(temperature, humidity),
regr_slope(temperature, humidity),
regr_sxx(temperature, humidity),
regr_sxy(temperature, humidity),
regr_syy(temperature, humidity),
stddev(temperature) as stddev_temp,
stddev_pop(temperature),
stddev_samp(temperature),
variance(temperature),
var_pop(temperature),
var_samp(temperature),
last(temperature, timec) as last_temp,
last(highlow, timec) as last_hl,
first(highlow, timec) as first_hl,
histogram(temperature, 0, 100, 5)
FROM conditions_before
GROUP BY bucket, location
HAVING min(location) >= 'NYC' and avg(temperature) > 2;
REFRESH MATERIALIZED VIEW cagg.realtime_mat;