Fix Hierarchical CAgg chunk_interval_size

When a Continuous Aggregate is created the `chunk_interval_size` is
defined my the `chunk_interval_size` of the original hypertable
multiplied by a fixed factor of 10.

The problem is currently when we create a Hierarchical Continuous
Aggregate the same factor is applied and it lead to an exponential
`chunk_interval_size`.

Fixed it by just copying the `chunk_interval_size` from the base
Continuous Aggregate for an Hierachical Continuous Aggreagate.

Fixes #5382
This commit is contained in:
Fabrízio de Royes Mello 2023-03-02 16:09:49 -03:00
parent 1423b55d18
commit 32046832d3
5 changed files with 557 additions and 143 deletions

View File

@ -12,6 +12,7 @@ accidentally triggering the load of a previous DB version.**
* #5336 Use NameData and namestrcpy for names * #5336 Use NameData and namestrcpy for names
* #5317 Fix some incorrect memory handling * #5317 Fix some incorrect memory handling
* #5367 Rename columns in old-style continuous aggregates * #5367 Rename columns in old-style continuous aggregates
* #5384 Fix Hierarchical Continuous Aggregates chunk_interval_size
**Thanks** **Thanks**
* @Medvecrab for discovering an issue with copying NameData when forming heap tuples. * @Medvecrab for discovering an issue with copying NameData when forming heap tuples.

View File

@ -205,7 +205,7 @@ static Var *mattablecolumninfo_addentry(MatTableColumnInfo *out, Node *input,
static void mattablecolumninfo_addinternal(MatTableColumnInfo *matcolinfo); static void mattablecolumninfo_addinternal(MatTableColumnInfo *matcolinfo);
static int32 mattablecolumninfo_create_materialization_table( static int32 mattablecolumninfo_create_materialization_table(
MatTableColumnInfo *matcolinfo, int32 hypertable_id, RangeVar *mat_rel, MatTableColumnInfo *matcolinfo, int32 hypertable_id, RangeVar *mat_rel,
CAggTimebucketInfo *origquery_tblinfo, bool create_addl_index, char *tablespacename, CAggTimebucketInfo *bucket_info, bool create_addl_index, char *tablespacename,
char *table_access_method, ObjectAddress *mataddress); char *table_access_method, ObjectAddress *mataddress);
static Query *mattablecolumninfo_get_partial_select_query(MatTableColumnInfo *mattblinfo, static Query *mattablecolumninfo_get_partial_select_query(MatTableColumnInfo *mattblinfo,
Query *userview_query, bool finalized); Query *userview_query, bool finalized);
@ -549,8 +549,8 @@ mattablecolumninfo_add_mattable_index(MatTableColumnInfo *matcolinfo, Hypertable
* *
* Parameters: * Parameters:
* mat_rel: relation information for the materialization table * mat_rel: relation information for the materialization table
* origquery_tblinfo: - user query's tbale information. used for setting up * bucket_info: bucket information used for setting up the
* thr partitioning of the hypertable. * hypertable partitioning (`chunk_interval_size`).
* tablespace_name: Name of the tablespace for the materialization table. * tablespace_name: Name of the tablespace for the materialization table.
* table_access_method: Name of the table access method to use for the * table_access_method: Name of the table access method to use for the
* materialization table. * materialization table.
@ -559,8 +559,7 @@ mattablecolumninfo_add_mattable_index(MatTableColumnInfo *matcolinfo, Hypertable
*/ */
static int32 static int32
mattablecolumninfo_create_materialization_table(MatTableColumnInfo *matcolinfo, int32 hypertable_id, mattablecolumninfo_create_materialization_table(MatTableColumnInfo *matcolinfo, int32 hypertable_id,
RangeVar *mat_rel, RangeVar *mat_rel, CAggTimebucketInfo *bucket_info,
CAggTimebucketInfo *origquery_tblinfo,
bool create_addl_index, char *const tablespacename, bool create_addl_index, char *const tablespacename,
char *const table_access_method, char *const table_access_method,
ObjectAddress *mataddress) ObjectAddress *mataddress)
@ -604,7 +603,12 @@ mattablecolumninfo_create_materialization_table(MatTableColumnInfo *matcolinfo,
RESTORE_USER(uid, saved_uid, sec_ctx); RESTORE_USER(uid, saved_uid, sec_ctx);
/* Convert the materialization table to a hypertable. */ /* Convert the materialization table to a hypertable. */
matpartcol_interval = MATPARTCOL_INTERVAL_FACTOR * (origquery_tblinfo->htpartcol_interval_len); matpartcol_interval = bucket_info->htpartcol_interval_len;
/* Apply the factor just for non-Hierachical CAggs */
if (bucket_info->parent_mat_hypertable_id == INVALID_HYPERTABLE_ID)
matpartcol_interval *= MATPARTCOL_INTERVAL_FACTOR;
cagg_create_hypertable(hypertable_id, mat_relid, matpartcolname, matpartcol_interval); cagg_create_hypertable(hypertable_id, mat_relid, matpartcolname, matpartcol_interval);
/* Retrieve the hypertable id from the cache. */ /* Retrieve the hypertable id from the cache. */
@ -621,7 +625,7 @@ mattablecolumninfo_create_materialization_table(MatTableColumnInfo *matcolinfo,
* aggregate. This is the initial state of the aggregate before any * aggregate. This is the initial state of the aggregate before any
* refreshes. * refreshes.
*/ */
orig_ht = ts_hypertable_cache_get_entry(hcache, origquery_tblinfo->htoid, CACHE_FLAG_NONE); orig_ht = ts_hypertable_cache_get_entry(hcache, bucket_info->htoid, CACHE_FLAG_NONE);
continuous_agg_invalidate_mat_ht(orig_ht, mat_ht, TS_TIME_NOBEGIN, TS_TIME_NOEND); continuous_agg_invalidate_mat_ht(orig_ht, mat_ht, TS_TIME_NOBEGIN, TS_TIME_NOEND);
ts_cache_release(hcache); ts_cache_release(hcache);
return mat_htid; return mat_htid;
@ -2615,7 +2619,7 @@ fixup_userview_query_tlist(Query *userquery, List *tlist_aliases)
*/ */
static void static void
cagg_create(const CreateTableAsStmt *create_stmt, ViewStmt *stmt, Query *panquery, cagg_create(const CreateTableAsStmt *create_stmt, ViewStmt *stmt, Query *panquery,
CAggTimebucketInfo *origquery_ht, WithClauseResult *with_clause_options) CAggTimebucketInfo *bucket_info, WithClauseResult *with_clause_options)
{ {
ObjectAddress mataddress; ObjectAddress mataddress;
char relnamebuf[NAMEDATALEN]; char relnamebuf[NAMEDATALEN];
@ -2668,7 +2672,7 @@ cagg_create(const CreateTableAsStmt *create_stmt, ViewStmt *stmt, Query *panquer
mattablecolumninfo_create_materialization_table(&mattblinfo, mattablecolumninfo_create_materialization_table(&mattblinfo,
materialize_hypertable_id, materialize_hypertable_id,
mat_rel, mat_rel,
origquery_ht, bucket_info,
is_create_mattbl_index, is_create_mattbl_index,
create_stmt->into->tableSpaceName, create_stmt->into->tableSpaceName,
create_stmt->into->accessMethod, create_stmt->into->accessMethod,
@ -2682,7 +2686,7 @@ cagg_create(const CreateTableAsStmt *create_stmt, ViewStmt *stmt, Query *panquer
mat_rel->relname); mat_rel->relname);
if (!materialized_only) if (!materialized_only)
final_selquery = build_union_query(origquery_ht, final_selquery = build_union_query(bucket_info,
mattblinfo.matpartcolno, mattblinfo.matpartcolno,
final_selquery, final_selquery,
panquery, panquery,
@ -2719,19 +2723,19 @@ cagg_create(const CreateTableAsStmt *create_stmt, ViewStmt *stmt, Query *panquer
nspid = RangeVarGetCreationNamespace(stmt->view); nspid = RangeVarGetCreationNamespace(stmt->view);
create_cagg_catalog_entry(materialize_hypertable_id, create_cagg_catalog_entry(materialize_hypertable_id,
origquery_ht->htid, bucket_info->htid,
get_namespace_name(nspid), /*schema name for user view */ get_namespace_name(nspid), /*schema name for user view */
stmt->view->relname, stmt->view->relname,
part_rel->schemaname, part_rel->schemaname,
part_rel->relname, part_rel->relname,
origquery_ht->bucket_width, bucket_info->bucket_width,
materialized_only, materialized_only,
dum_rel->schemaname, dum_rel->schemaname,
dum_rel->relname, dum_rel->relname,
finalized, finalized,
origquery_ht->parent_mat_hypertable_id); bucket_info->parent_mat_hypertable_id);
if (origquery_ht->bucket_width == BUCKET_WIDTH_VARIABLE) if (bucket_info->bucket_width == BUCKET_WIDTH_VARIABLE)
{ {
const char *bucket_width; const char *bucket_width;
const char *origin = ""; const char *origin = "";
@ -2739,14 +2743,14 @@ cagg_create(const CreateTableAsStmt *create_stmt, ViewStmt *stmt, Query *panquer
/* /*
* Variable-sized buckets work only with intervals. * Variable-sized buckets work only with intervals.
*/ */
Assert(origquery_ht->interval != NULL); Assert(bucket_info->interval != NULL);
bucket_width = DatumGetCString( bucket_width = DatumGetCString(
DirectFunctionCall1(interval_out, IntervalPGetDatum(origquery_ht->interval))); DirectFunctionCall1(interval_out, IntervalPGetDatum(bucket_info->interval)));
if (!TIMESTAMP_NOT_FINITE(origquery_ht->origin)) if (!TIMESTAMP_NOT_FINITE(bucket_info->origin))
{ {
origin = DatumGetCString( origin = DatumGetCString(
DirectFunctionCall1(timestamp_out, TimestampGetDatum(origquery_ht->origin))); DirectFunctionCall1(timestamp_out, TimestampGetDatum(bucket_info->origin)));
} }
/* /*
@ -2757,17 +2761,16 @@ cagg_create(const CreateTableAsStmt *create_stmt, ViewStmt *stmt, Query *panquer
* that can be optimized later. * that can be optimized later.
*/ */
create_bucket_function_catalog_entry(materialize_hypertable_id, create_bucket_function_catalog_entry(materialize_hypertable_id,
get_func_namespace( get_func_namespace(bucket_info->bucket_func->funcid) !=
origquery_ht->bucket_func->funcid) !=
PG_PUBLIC_NAMESPACE, PG_PUBLIC_NAMESPACE,
get_func_name(origquery_ht->bucket_func->funcid), get_func_name(bucket_info->bucket_func->funcid),
bucket_width, bucket_width,
origin, origin,
origquery_ht->timezone); bucket_info->timezone);
} }
/* Step 5: Create trigger on raw hypertable -specified in the user view query. */ /* Step 5: Create trigger on raw hypertable -specified in the user view query. */
cagg_add_trigger_hypertable(origquery_ht->htoid, origquery_ht->htid); cagg_add_trigger_hypertable(bucket_info->htoid, bucket_info->htid);
} }
DDLResult DDLResult

View File

@ -123,6 +123,38 @@ SELECT
FROM :CAGG_NAME_2TH_LEVEL FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
name | chunk_interval
-------------------------+----------------
conditions | 10
conditions_summary_1_1 | 100
conditions_summary_2_5 | 100
conditions_summary_3_10 | 100
(4 rows)
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
bucket | temperature bucket | temperature
@ -328,21 +360,21 @@ SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it depends of other CAGGs -- should error because it depends of other CAGGs
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:124: ERROR: cannot drop view conditions_summary_1_1 because other objects depend on it psql:include/cagg_on_cagg_common.sql:150: ERROR: cannot drop view conditions_summary_1_1 because other objects depend on it
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:125: ERROR: cannot drop view conditions_summary_2_5 because other objects depend on it psql:include/cagg_on_cagg_common.sql:151: ERROR: cannot drop view conditions_summary_2_5 because other objects depend on it
CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:126: NOTICE: continuous aggregate "conditions_summary_1_1" is already up-to-date psql:include/cagg_on_cagg_common.sql:152: NOTICE: continuous aggregate "conditions_summary_1_1" is already up-to-date
CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:127: NOTICE: continuous aggregate "conditions_summary_2_5" is already up-to-date psql:include/cagg_on_cagg_common.sql:153: NOTICE: continuous aggregate "conditions_summary_2_5" is already up-to-date
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- DROP the 3TH level CAGG don't affect others -- DROP the 3TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:131: NOTICE: drop cascades to table _timescaledb_internal._hyper_4_4_chunk psql:include/cagg_on_cagg_common.sql:157: NOTICE: drop cascades to table _timescaledb_internal._hyper_4_4_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:134: ERROR: relation "conditions_summary_3_10" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:160: ERROR: relation "conditions_summary_3_10" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -365,11 +397,11 @@ SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
-- DROP the 2TH level CAGG don't affect others -- DROP the 2TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:145: NOTICE: drop cascades to table _timescaledb_internal._hyper_3_3_chunk psql:include/cagg_on_cagg_common.sql:171: NOTICE: drop cascades to table _timescaledb_internal._hyper_3_3_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:148: ERROR: relation "conditions_summary_2_5" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:174: ERROR: relation "conditions_summary_2_5" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -384,11 +416,11 @@ SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
-- DROP the first CAGG should work -- DROP the first CAGG should work
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:155: NOTICE: drop cascades to table _timescaledb_internal._hyper_2_2_chunk psql:include/cagg_on_cagg_common.sql:181: NOTICE: drop cascades to table _timescaledb_internal._hyper_2_2_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:158: ERROR: relation "conditions_summary_1_1" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:184: ERROR: relation "conditions_summary_1_1" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- Default tests -- Default tests
\set IS_DEFAULT_COLUMN_ORDER TRUE \set IS_DEFAULT_COLUMN_ORDER TRUE
@ -492,6 +524,38 @@ SELECT
FROM :CAGG_NAME_2TH_LEVEL FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
name | chunk_interval
-------------------------+----------------
conditions | 10
conditions_summary_1_1 | 100
conditions_summary_2_5 | 100
conditions_summary_3_10 | 100
(4 rows)
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
bucket | temperature bucket | temperature
@ -697,21 +761,21 @@ SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it depends of other CAGGs -- should error because it depends of other CAGGs
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:124: ERROR: cannot drop view conditions_summary_1_1 because other objects depend on it psql:include/cagg_on_cagg_common.sql:150: ERROR: cannot drop view conditions_summary_1_1 because other objects depend on it
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:125: ERROR: cannot drop view conditions_summary_2_5 because other objects depend on it psql:include/cagg_on_cagg_common.sql:151: ERROR: cannot drop view conditions_summary_2_5 because other objects depend on it
CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:126: NOTICE: continuous aggregate "conditions_summary_1_1" is already up-to-date psql:include/cagg_on_cagg_common.sql:152: NOTICE: continuous aggregate "conditions_summary_1_1" is already up-to-date
CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:127: NOTICE: continuous aggregate "conditions_summary_2_5" is already up-to-date psql:include/cagg_on_cagg_common.sql:153: NOTICE: continuous aggregate "conditions_summary_2_5" is already up-to-date
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- DROP the 3TH level CAGG don't affect others -- DROP the 3TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:131: NOTICE: drop cascades to table _timescaledb_internal._hyper_8_9_chunk psql:include/cagg_on_cagg_common.sql:157: NOTICE: drop cascades to table _timescaledb_internal._hyper_8_9_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:134: ERROR: relation "conditions_summary_3_10" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:160: ERROR: relation "conditions_summary_3_10" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -734,11 +798,11 @@ SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
-- DROP the 2TH level CAGG don't affect others -- DROP the 2TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:145: NOTICE: drop cascades to table _timescaledb_internal._hyper_7_8_chunk psql:include/cagg_on_cagg_common.sql:171: NOTICE: drop cascades to table _timescaledb_internal._hyper_7_8_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:148: ERROR: relation "conditions_summary_2_5" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:174: ERROR: relation "conditions_summary_2_5" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -753,11 +817,11 @@ SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
-- DROP the first CAGG should work -- DROP the first CAGG should work
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:155: NOTICE: drop cascades to table _timescaledb_internal._hyper_6_7_chunk psql:include/cagg_on_cagg_common.sql:181: NOTICE: drop cascades to table _timescaledb_internal._hyper_6_7_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:158: ERROR: relation "conditions_summary_1_1" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:184: ERROR: relation "conditions_summary_1_1" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- --
-- Validation test for non-multiple bucket sizes -- Validation test for non-multiple bucket sizes
@ -1112,6 +1176,38 @@ SELECT
FROM :CAGG_NAME_2TH_LEVEL FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
name | chunk_interval
-----------------------------+----------------
conditions | @ 7 days
conditions_summary_1_hourly | @ 70 days
conditions_summary_2_daily | @ 70 days
conditions_summary_3_weekly | @ 70 days
(4 rows)
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
bucket | temperature bucket | temperature
@ -1317,21 +1413,21 @@ SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it depends of other CAGGs -- should error because it depends of other CAGGs
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:124: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it psql:include/cagg_on_cagg_common.sql:150: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:125: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it psql:include/cagg_on_cagg_common.sql:151: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it
CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:126: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date psql:include/cagg_on_cagg_common.sql:152: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date
CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:127: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date psql:include/cagg_on_cagg_common.sql:153: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- DROP the 3TH level CAGG don't affect others -- DROP the 3TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:131: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_14_chunk psql:include/cagg_on_cagg_common.sql:157: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_14_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:134: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:160: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -1354,11 +1450,11 @@ SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
-- DROP the 2TH level CAGG don't affect others -- DROP the 2TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:145: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_13_chunk psql:include/cagg_on_cagg_common.sql:171: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_13_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:148: ERROR: relation "conditions_summary_2_daily" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:174: ERROR: relation "conditions_summary_2_daily" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -1373,11 +1469,11 @@ SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
-- DROP the first CAGG should work -- DROP the first CAGG should work
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:155: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_12_chunk psql:include/cagg_on_cagg_common.sql:181: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_12_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:158: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:184: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- Default tests -- Default tests
\set IS_DEFAULT_COLUMN_ORDER TRUE \set IS_DEFAULT_COLUMN_ORDER TRUE
@ -1477,6 +1573,38 @@ SELECT
FROM :CAGG_NAME_2TH_LEVEL FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
name | chunk_interval
-----------------------------+----------------
conditions | @ 7 days
conditions_summary_1_hourly | @ 70 days
conditions_summary_2_daily | @ 70 days
conditions_summary_3_weekly | @ 70 days
(4 rows)
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
bucket | temperature bucket | temperature
@ -1682,21 +1810,21 @@ SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it depends of other CAGGs -- should error because it depends of other CAGGs
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:124: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it psql:include/cagg_on_cagg_common.sql:150: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:125: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it psql:include/cagg_on_cagg_common.sql:151: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it
CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:126: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date psql:include/cagg_on_cagg_common.sql:152: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date
CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:127: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date psql:include/cagg_on_cagg_common.sql:153: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- DROP the 3TH level CAGG don't affect others -- DROP the 3TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:131: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_18_chunk psql:include/cagg_on_cagg_common.sql:157: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_18_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:134: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:160: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -1719,11 +1847,11 @@ SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
-- DROP the 2TH level CAGG don't affect others -- DROP the 2TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:145: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_17_chunk psql:include/cagg_on_cagg_common.sql:171: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_17_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:148: ERROR: relation "conditions_summary_2_daily" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:174: ERROR: relation "conditions_summary_2_daily" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -1738,11 +1866,11 @@ SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
-- DROP the first CAGG should work -- DROP the first CAGG should work
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:155: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_16_chunk psql:include/cagg_on_cagg_common.sql:181: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_16_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:158: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:184: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- --
-- Validation test for variable bucket on top of fixed bucket -- Validation test for variable bucket on top of fixed bucket
@ -2172,6 +2300,38 @@ SELECT
FROM :CAGG_NAME_2TH_LEVEL FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
name | chunk_interval
-----------------------------+----------------
conditions | @ 7 days
conditions_summary_1_hourly | @ 70 days
conditions_summary_2_daily | @ 70 days
conditions_summary_3_weekly | @ 70 days
(4 rows)
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
bucket | temperature bucket | temperature
@ -2377,21 +2537,21 @@ SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it depends of other CAGGs -- should error because it depends of other CAGGs
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:124: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it psql:include/cagg_on_cagg_common.sql:150: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:125: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it psql:include/cagg_on_cagg_common.sql:151: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it
CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:126: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date psql:include/cagg_on_cagg_common.sql:152: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date
CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:127: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date psql:include/cagg_on_cagg_common.sql:153: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- DROP the 3TH level CAGG don't affect others -- DROP the 3TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:131: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_22_chunk psql:include/cagg_on_cagg_common.sql:157: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_22_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:134: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:160: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -2414,11 +2574,11 @@ SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
-- DROP the 2TH level CAGG don't affect others -- DROP the 2TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:145: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_21_chunk psql:include/cagg_on_cagg_common.sql:171: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_21_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:148: ERROR: relation "conditions_summary_2_daily" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:174: ERROR: relation "conditions_summary_2_daily" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -2433,11 +2593,11 @@ SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
-- DROP the first CAGG should work -- DROP the first CAGG should work
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:155: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_20_chunk psql:include/cagg_on_cagg_common.sql:181: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_20_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:158: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:184: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- Default tests -- Default tests
\set IS_DEFAULT_COLUMN_ORDER TRUE \set IS_DEFAULT_COLUMN_ORDER TRUE
@ -2536,6 +2696,38 @@ SELECT
FROM :CAGG_NAME_2TH_LEVEL FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
name | chunk_interval
-----------------------------+----------------
conditions | @ 7 days
conditions_summary_1_hourly | @ 70 days
conditions_summary_2_daily | @ 70 days
conditions_summary_3_weekly | @ 70 days
(4 rows)
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
bucket | temperature bucket | temperature
@ -2741,21 +2933,21 @@ SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it depends of other CAGGs -- should error because it depends of other CAGGs
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:124: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it psql:include/cagg_on_cagg_common.sql:150: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:125: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it psql:include/cagg_on_cagg_common.sql:151: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it
CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:126: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date psql:include/cagg_on_cagg_common.sql:152: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date
CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:127: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date psql:include/cagg_on_cagg_common.sql:153: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- DROP the 3TH level CAGG don't affect others -- DROP the 3TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:131: NOTICE: drop cascades to table _timescaledb_internal._hyper_33_26_chunk psql:include/cagg_on_cagg_common.sql:157: NOTICE: drop cascades to table _timescaledb_internal._hyper_33_26_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:134: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:160: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -2778,11 +2970,11 @@ SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
-- DROP the 2TH level CAGG don't affect others -- DROP the 2TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:145: NOTICE: drop cascades to table _timescaledb_internal._hyper_32_25_chunk psql:include/cagg_on_cagg_common.sql:171: NOTICE: drop cascades to table _timescaledb_internal._hyper_32_25_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:148: ERROR: relation "conditions_summary_2_daily" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:174: ERROR: relation "conditions_summary_2_daily" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -2797,11 +2989,11 @@ SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
-- DROP the first CAGG should work -- DROP the first CAGG should work
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:155: NOTICE: drop cascades to table _timescaledb_internal._hyper_31_24_chunk psql:include/cagg_on_cagg_common.sql:181: NOTICE: drop cascades to table _timescaledb_internal._hyper_31_24_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:158: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:184: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- --
-- Validation test for variable bucket on top of fixed bucket -- Validation test for variable bucket on top of fixed bucket

View File

@ -157,6 +157,38 @@ SELECT
FROM :CAGG_NAME_2TH_LEVEL FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
name | chunk_interval
-------------------------+----------------
conditions | 10
conditions_summary_1_1 | 100
conditions_summary_2_5 | 100
conditions_summary_3_10 | 100
(4 rows)
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
bucket | temperature bucket | temperature
@ -362,21 +394,21 @@ SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it depends of other CAGGs -- should error because it depends of other CAGGs
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:124: ERROR: cannot drop view conditions_summary_1_1 because other objects depend on it psql:include/cagg_on_cagg_common.sql:150: ERROR: cannot drop view conditions_summary_1_1 because other objects depend on it
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:125: ERROR: cannot drop view conditions_summary_2_5 because other objects depend on it psql:include/cagg_on_cagg_common.sql:151: ERROR: cannot drop view conditions_summary_2_5 because other objects depend on it
CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:126: NOTICE: continuous aggregate "conditions_summary_1_1" is already up-to-date psql:include/cagg_on_cagg_common.sql:152: NOTICE: continuous aggregate "conditions_summary_1_1" is already up-to-date
CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:127: NOTICE: continuous aggregate "conditions_summary_2_5" is already up-to-date psql:include/cagg_on_cagg_common.sql:153: NOTICE: continuous aggregate "conditions_summary_2_5" is already up-to-date
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- DROP the 3TH level CAGG don't affect others -- DROP the 3TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:131: NOTICE: drop cascades to table _timescaledb_internal._hyper_4_4_chunk psql:include/cagg_on_cagg_common.sql:157: NOTICE: drop cascades to table _timescaledb_internal._hyper_4_4_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:134: ERROR: relation "conditions_summary_3_10" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:160: ERROR: relation "conditions_summary_3_10" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -399,11 +431,11 @@ SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
-- DROP the 2TH level CAGG don't affect others -- DROP the 2TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:145: NOTICE: drop cascades to table _timescaledb_internal._hyper_3_3_chunk psql:include/cagg_on_cagg_common.sql:171: NOTICE: drop cascades to table _timescaledb_internal._hyper_3_3_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:148: ERROR: relation "conditions_summary_2_5" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:174: ERROR: relation "conditions_summary_2_5" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -418,11 +450,11 @@ SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
-- DROP the first CAGG should work -- DROP the first CAGG should work
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:155: NOTICE: drop cascades to table _timescaledb_internal._hyper_2_2_chunk psql:include/cagg_on_cagg_common.sql:181: NOTICE: drop cascades to table _timescaledb_internal._hyper_2_2_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:158: ERROR: relation "conditions_summary_1_1" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:184: ERROR: relation "conditions_summary_1_1" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- Default tests -- Default tests
\set IS_DEFAULT_COLUMN_ORDER TRUE \set IS_DEFAULT_COLUMN_ORDER TRUE
@ -526,6 +558,38 @@ SELECT
FROM :CAGG_NAME_2TH_LEVEL FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
name | chunk_interval
-------------------------+----------------
conditions | 10
conditions_summary_1_1 | 100
conditions_summary_2_5 | 100
conditions_summary_3_10 | 100
(4 rows)
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
bucket | temperature bucket | temperature
@ -731,21 +795,21 @@ SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it depends of other CAGGs -- should error because it depends of other CAGGs
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:124: ERROR: cannot drop view conditions_summary_1_1 because other objects depend on it psql:include/cagg_on_cagg_common.sql:150: ERROR: cannot drop view conditions_summary_1_1 because other objects depend on it
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:125: ERROR: cannot drop view conditions_summary_2_5 because other objects depend on it psql:include/cagg_on_cagg_common.sql:151: ERROR: cannot drop view conditions_summary_2_5 because other objects depend on it
CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:126: NOTICE: continuous aggregate "conditions_summary_1_1" is already up-to-date psql:include/cagg_on_cagg_common.sql:152: NOTICE: continuous aggregate "conditions_summary_1_1" is already up-to-date
CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:127: NOTICE: continuous aggregate "conditions_summary_2_5" is already up-to-date psql:include/cagg_on_cagg_common.sql:153: NOTICE: continuous aggregate "conditions_summary_2_5" is already up-to-date
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- DROP the 3TH level CAGG don't affect others -- DROP the 3TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:131: NOTICE: drop cascades to table _timescaledb_internal._hyper_8_9_chunk psql:include/cagg_on_cagg_common.sql:157: NOTICE: drop cascades to table _timescaledb_internal._hyper_8_9_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:134: ERROR: relation "conditions_summary_3_10" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:160: ERROR: relation "conditions_summary_3_10" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -768,11 +832,11 @@ SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
-- DROP the 2TH level CAGG don't affect others -- DROP the 2TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:145: NOTICE: drop cascades to table _timescaledb_internal._hyper_7_8_chunk psql:include/cagg_on_cagg_common.sql:171: NOTICE: drop cascades to table _timescaledb_internal._hyper_7_8_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:148: ERROR: relation "conditions_summary_2_5" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:174: ERROR: relation "conditions_summary_2_5" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -787,11 +851,11 @@ SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
-- DROP the first CAGG should work -- DROP the first CAGG should work
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:155: NOTICE: drop cascades to table _timescaledb_internal._hyper_6_7_chunk psql:include/cagg_on_cagg_common.sql:181: NOTICE: drop cascades to table _timescaledb_internal._hyper_6_7_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:158: ERROR: relation "conditions_summary_1_1" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:184: ERROR: relation "conditions_summary_1_1" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- --
-- Validation test for non-multiple bucket sizes -- Validation test for non-multiple bucket sizes
@ -1149,6 +1213,38 @@ SELECT
FROM :CAGG_NAME_2TH_LEVEL FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
name | chunk_interval
-----------------------------+----------------
conditions | @ 7 days
conditions_summary_1_hourly | @ 70 days
conditions_summary_2_daily | @ 70 days
conditions_summary_3_weekly | @ 70 days
(4 rows)
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
bucket | temperature bucket | temperature
@ -1354,21 +1450,21 @@ SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it depends of other CAGGs -- should error because it depends of other CAGGs
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:124: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it psql:include/cagg_on_cagg_common.sql:150: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:125: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it psql:include/cagg_on_cagg_common.sql:151: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it
CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:126: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date psql:include/cagg_on_cagg_common.sql:152: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date
CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:127: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date psql:include/cagg_on_cagg_common.sql:153: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- DROP the 3TH level CAGG don't affect others -- DROP the 3TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:131: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_14_chunk psql:include/cagg_on_cagg_common.sql:157: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_14_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:134: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:160: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -1391,11 +1487,11 @@ SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
-- DROP the 2TH level CAGG don't affect others -- DROP the 2TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:145: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_13_chunk psql:include/cagg_on_cagg_common.sql:171: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_13_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:148: ERROR: relation "conditions_summary_2_daily" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:174: ERROR: relation "conditions_summary_2_daily" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -1410,11 +1506,11 @@ SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
-- DROP the first CAGG should work -- DROP the first CAGG should work
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:155: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_12_chunk psql:include/cagg_on_cagg_common.sql:181: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_12_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:158: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:184: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- Default tests -- Default tests
\set IS_DEFAULT_COLUMN_ORDER TRUE \set IS_DEFAULT_COLUMN_ORDER TRUE
@ -1514,6 +1610,38 @@ SELECT
FROM :CAGG_NAME_2TH_LEVEL FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
name | chunk_interval
-----------------------------+----------------
conditions | @ 7 days
conditions_summary_1_hourly | @ 70 days
conditions_summary_2_daily | @ 70 days
conditions_summary_3_weekly | @ 70 days
(4 rows)
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
bucket | temperature bucket | temperature
@ -1719,21 +1847,21 @@ SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it depends of other CAGGs -- should error because it depends of other CAGGs
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:124: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it psql:include/cagg_on_cagg_common.sql:150: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:125: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it psql:include/cagg_on_cagg_common.sql:151: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it
CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:126: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date psql:include/cagg_on_cagg_common.sql:152: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date
CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:127: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date psql:include/cagg_on_cagg_common.sql:153: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- DROP the 3TH level CAGG don't affect others -- DROP the 3TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:131: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_18_chunk psql:include/cagg_on_cagg_common.sql:157: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_18_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:134: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:160: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -1756,11 +1884,11 @@ SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
-- DROP the 2TH level CAGG don't affect others -- DROP the 2TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:145: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_17_chunk psql:include/cagg_on_cagg_common.sql:171: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_17_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:148: ERROR: relation "conditions_summary_2_daily" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:174: ERROR: relation "conditions_summary_2_daily" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -1775,11 +1903,11 @@ SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
-- DROP the first CAGG should work -- DROP the first CAGG should work
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:155: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_16_chunk psql:include/cagg_on_cagg_common.sql:181: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_16_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:158: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:184: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- --
-- Validation test for variable bucket on top of fixed bucket -- Validation test for variable bucket on top of fixed bucket
@ -2209,6 +2337,38 @@ SELECT
FROM :CAGG_NAME_2TH_LEVEL FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
name | chunk_interval
-----------------------------+----------------
conditions | @ 7 days
conditions_summary_1_hourly | @ 70 days
conditions_summary_2_daily | @ 70 days
conditions_summary_3_weekly | @ 70 days
(4 rows)
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
bucket | temperature bucket | temperature
@ -2414,21 +2574,21 @@ SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it depends of other CAGGs -- should error because it depends of other CAGGs
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:124: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it psql:include/cagg_on_cagg_common.sql:150: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:125: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it psql:include/cagg_on_cagg_common.sql:151: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it
CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:126: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date psql:include/cagg_on_cagg_common.sql:152: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date
CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:127: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date psql:include/cagg_on_cagg_common.sql:153: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- DROP the 3TH level CAGG don't affect others -- DROP the 3TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:131: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_22_chunk psql:include/cagg_on_cagg_common.sql:157: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_22_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:134: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:160: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -2451,11 +2611,11 @@ SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
-- DROP the 2TH level CAGG don't affect others -- DROP the 2TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:145: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_21_chunk psql:include/cagg_on_cagg_common.sql:171: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_21_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:148: ERROR: relation "conditions_summary_2_daily" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:174: ERROR: relation "conditions_summary_2_daily" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -2470,11 +2630,11 @@ SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
-- DROP the first CAGG should work -- DROP the first CAGG should work
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:155: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_20_chunk psql:include/cagg_on_cagg_common.sql:181: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_20_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:158: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:184: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- Default tests -- Default tests
\set IS_DEFAULT_COLUMN_ORDER TRUE \set IS_DEFAULT_COLUMN_ORDER TRUE
@ -2573,6 +2733,38 @@ SELECT
FROM :CAGG_NAME_2TH_LEVEL FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
name | chunk_interval
-----------------------------+----------------
conditions | @ 7 days
conditions_summary_1_hourly | @ 70 days
conditions_summary_2_daily | @ 70 days
conditions_summary_3_weekly | @ 70 days
(4 rows)
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
bucket | temperature bucket | temperature
@ -2778,21 +2970,21 @@ SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it depends of other CAGGs -- should error because it depends of other CAGGs
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:124: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it psql:include/cagg_on_cagg_common.sql:150: ERROR: cannot drop view conditions_summary_1_hourly because other objects depend on it
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:125: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it psql:include/cagg_on_cagg_common.sql:151: ERROR: cannot drop view conditions_summary_2_daily because other objects depend on it
CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_1ST_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:126: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date psql:include/cagg_on_cagg_common.sql:152: NOTICE: continuous aggregate "conditions_summary_1_hourly" is already up-to-date
CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL); CALL refresh_continuous_aggregate(:'CAGG_NAME_2TH_LEVEL', NULL, NULL);
psql:include/cagg_on_cagg_common.sql:127: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date psql:include/cagg_on_cagg_common.sql:153: NOTICE: continuous aggregate "conditions_summary_2_daily" is already up-to-date
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- DROP the 3TH level CAGG don't affect others -- DROP the 3TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_3TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:131: NOTICE: drop cascades to table _timescaledb_internal._hyper_33_26_chunk psql:include/cagg_on_cagg_common.sql:157: NOTICE: drop cascades to table _timescaledb_internal._hyper_33_26_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_3TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:134: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:160: ERROR: relation "conditions_summary_3_weekly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -2815,11 +3007,11 @@ SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
-- DROP the 2TH level CAGG don't affect others -- DROP the 2TH level CAGG don't affect others
DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_2TH_LEVEL;
psql:include/cagg_on_cagg_common.sql:145: NOTICE: drop cascades to table _timescaledb_internal._hyper_32_25_chunk psql:include/cagg_on_cagg_common.sql:171: NOTICE: drop cascades to table _timescaledb_internal._hyper_32_25_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:148: ERROR: relation "conditions_summary_2_daily" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:174: ERROR: relation "conditions_summary_2_daily" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- should work because dropping the top level CAGG -- should work because dropping the top level CAGG
-- don't affect the down level CAGGs -- don't affect the down level CAGGs
@ -2834,11 +3026,11 @@ SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
-- DROP the first CAGG should work -- DROP the first CAGG should work
DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL; DROP MATERIALIZED VIEW :CAGG_NAME_1ST_LEVEL;
psql:include/cagg_on_cagg_common.sql:155: NOTICE: drop cascades to table _timescaledb_internal._hyper_31_24_chunk psql:include/cagg_on_cagg_common.sql:181: NOTICE: drop cascades to table _timescaledb_internal._hyper_31_24_chunk
\set ON_ERROR_STOP 0 \set ON_ERROR_STOP 0
-- should error because it was dropped -- should error because it was dropped
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
psql:include/cagg_on_cagg_common.sql:158: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15 psql:include/cagg_on_cagg_common.sql:184: ERROR: relation "conditions_summary_1_hourly" does not exist at character 15
\set ON_ERROR_STOP 1 \set ON_ERROR_STOP 1
-- --
-- Validation test for variable bucket on top of fixed bucket -- Validation test for variable bucket on top of fixed bucket

View File

@ -32,6 +32,32 @@ FROM :CAGG_NAME_2TH_LEVEL
GROUP BY 1 GROUP BY 1
WITH NO DATA; WITH NO DATA;
-- Check chunk_interval
\if :IS_TIME_DIMENSION
SELECT h.table_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, _timescaledb_internal.to_interval(d.interval_length) AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\else
SELECT h.table_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.hypertable h
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = h.id
WHERE h.table_name = 'conditions'
UNION ALL
SELECT c.user_view_name AS name, d.interval_length AS chunk_interval
FROM _timescaledb_catalog.continuous_agg c
LEFT JOIN _timescaledb_catalog.dimension d on d.hypertable_id = c.mat_hypertable_id
WHERE c.user_view_name IN (:'CAGG_NAME_1ST_LEVEL', :'CAGG_NAME_2TH_LEVEL', :'CAGG_NAME_3TH_LEVEL')
ORDER BY 1, 2;
\endif
-- No data because the CAGGs are just for materialized data -- No data because the CAGGs are just for materialized data
SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_1ST_LEVEL ORDER BY bucket;
SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket; SELECT * FROM :CAGG_NAME_2TH_LEVEL ORDER BY bucket;