diff --git a/sql/pre_install/tables.sql b/sql/pre_install/tables.sql index 9389d315a9a..aa9b58e04fb 100644 --- a/sql/pre_install/tables.sql +++ b/sql/pre_install/tables.sql @@ -387,29 +387,6 @@ CREATE INDEX continuous_agg_raw_hypertable_id_idx ON _timescaledb_catalog.contin SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.continuous_agg', ''); --- See the comments for ContinuousAggsBucketFunction structure. -CREATE TABLE _timescaledb_catalog.continuous_aggs_bucket_function ( - mat_hypertable_id integer NOT NULL, - -- The bucket function - bucket_func text NOT NULL, - -- `bucket_width` argument of the function, e.g. "1 month" - bucket_width text NOT NULL, - -- optional `origin` argument of the function provided by the user - bucket_origin text, - -- optional `offset` argument of the function provided by the user - bucket_offset text, - -- optional `timezone` argument of the function provided by the user - bucket_timezone text, - -- fixed or variable sized bucket - bucket_fixed_width bool NOT NULL, - -- table constraints - CONSTRAINT continuous_aggs_bucket_function_pkey PRIMARY KEY (mat_hypertable_id), - CONSTRAINT continuous_aggs_bucket_function_mat_hypertable_id_fkey FOREIGN KEY (mat_hypertable_id) REFERENCES _timescaledb_catalog.hypertable (id) ON DELETE CASCADE, - CONSTRAINT continuous_aggs_bucket_function_func_check CHECK (pg_catalog.to_regprocedure(bucket_func) IS DISTINCT FROM 0) -); - -SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.continuous_aggs_bucket_function', ''); - CREATE TABLE _timescaledb_catalog.continuous_aggs_invalidation_threshold ( hypertable_id integer NOT NULL, watermark bigint NOT NULL, diff --git a/sql/updates/latest-dev.sql b/sql/updates/latest-dev.sql index d233b0ae5f8..5533c3c058b 100644 --- a/sql/updates/latest-dev.sql +++ b/sql/updates/latest-dev.sql @@ -114,3 +114,9 @@ CREATE FUNCTION @extschema@.hypertable_columnstore_stats (hypertable REGCLASS) STABLE STRICT AS 'SELECT * FROM @extschema@.hypertable_compression_stats($1)' SET search_path TO pg_catalog, pg_temp; + +-- Remove useless catalog metadata +ALTER EXTENSION timescaledb + DROP TABLE _timescaledb_catalog.continuous_aggs_bucket_function; + +DROP TABLE _timescaledb_catalog.continuous_aggs_bucket_function; diff --git a/sql/updates/reverse-dev.sql b/sql/updates/reverse-dev.sql index 6b75bc1c851..64ac0ec3762 100644 --- a/sql/updates/reverse-dev.sql +++ b/sql/updates/reverse-dev.sql @@ -57,3 +57,32 @@ ALTER EXTENSION timescaledb DROP VIEW timescaledb_information.chunk_columnstore_ DROP VIEW timescaledb_information.hypertable_columnstore_settings; DROP VIEW timescaledb_information.chunk_columnstore_settings; +-- Restore the removed metadata table +CREATE TABLE _timescaledb_catalog.continuous_aggs_bucket_function ( + mat_hypertable_id integer NOT NULL, + -- The bucket function + bucket_func text NOT NULL, + -- `bucket_width` argument of the function, e.g. "1 month" + bucket_width text NOT NULL, + -- optional `origin` argument of the function provided by the user + bucket_origin text, + -- optional `offset` argument of the function provided by the user + bucket_offset text, + -- optional `timezone` argument of the function provided by the user + bucket_timezone text, + -- fixed or variable sized bucket + bucket_fixed_width bool NOT NULL, + -- table constraints + CONSTRAINT continuous_aggs_bucket_function_pkey PRIMARY KEY (mat_hypertable_id), + CONSTRAINT continuous_aggs_bucket_function_mat_hypertable_id_fkey FOREIGN KEY (mat_hypertable_id) REFERENCES _timescaledb_catalog.hypertable (id) ON DELETE CASCADE, + CONSTRAINT continuous_aggs_bucket_function_func_check CHECK (pg_catalog.to_regprocedure(bucket_func) IS DISTINCT FROM 0) +); + +INSERT INTO _timescaledb_catalog.continuous_aggs_bucket_function + (mat_hypertable_id, bucket_func, bucket_width, bucket_origin, bucket_offset, bucket_timezone, bucket_fixed_width) +SELECT mat_hypertable_id, bf.bucket_func::text, bf.bucket_width, bf.bucket_origin, bf.bucket_offset, bf.bucket_timezone, bf.bucket_fixed_width +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id) AS bf; + +SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.continuous_aggs_bucket_function', ''); + +GRANT SELECT ON _timescaledb_catalog.continuous_aggs_bucket_function TO PUBLIC; diff --git a/src/cross_module_fn.c b/src/cross_module_fn.c index 5f1b5a0290e..1814ac94bf9 100644 --- a/src/cross_module_fn.c +++ b/src/cross_module_fn.c @@ -284,6 +284,13 @@ continuous_agg_call_invalidation_trigger_default(int32 hypertable_id, Relation c pg_unreachable(); } +static ContinuousAggsBucketFunction * +continuous_agg_get_bucket_function_info_internal_default(Oid view_oid) +{ + error_no_default_fn_community(); + pg_unreachable(); +} + TS_FUNCTION_INFO_V1(ts_tsl_loaded); PGDLLEXPORT Datum @@ -373,6 +380,8 @@ TSDLLEXPORT CrossModuleFunctions ts_cm_functions_default = { .continuous_agg_validate_query = error_no_default_fn_pg_community, .continuous_agg_get_bucket_function = error_no_default_fn_pg_community, .continuous_agg_get_bucket_function_info = error_no_default_fn_pg_community, + .continuous_agg_get_bucket_function_info_internal = + continuous_agg_get_bucket_function_info_internal_default, .continuous_agg_migrate_to_time_bucket = error_no_default_fn_pg_community, .cagg_try_repair = process_cagg_try_repair, diff --git a/src/cross_module_fn.h b/src/cross_module_fn.h index e471a867b25..c8bf2085928 100644 --- a/src/cross_module_fn.h +++ b/src/cross_module_fn.h @@ -117,6 +117,7 @@ typedef struct CrossModuleFunctions PGFunction continuous_agg_get_bucket_function_info; PGFunction continuous_agg_migrate_to_time_bucket; PGFunction cagg_try_repair; + ContinuousAggsBucketFunction *(*continuous_agg_get_bucket_function_info_internal)(Oid view_oid); PGFunction compressed_data_send; PGFunction compressed_data_recv; diff --git a/src/ts_catalog/catalog.c b/src/ts_catalog/catalog.c index 4278ac763c0..4645e3b77ea 100644 --- a/src/ts_catalog/catalog.c +++ b/src/ts_catalog/catalog.c @@ -97,10 +97,6 @@ static const TableInfoDef catalog_table_names[_MAX_CATALOG_TABLES + 1] = { .schema_name = CATALOG_SCHEMA_NAME, .table_name = COMPRESSION_CHUNK_SIZE_TABLE_NAME, }, - [CONTINUOUS_AGGS_BUCKET_FUNCTION] = { - .schema_name = CATALOG_SCHEMA_NAME, - .table_name = CONTINUOUS_AGGS_BUCKET_FUNCTION_TABLE_NAME, - }, [CONTINUOUS_AGGS_WATERMARK] = { .schema_name = CATALOG_SCHEMA_NAME, .table_name = CONTINUOUS_AGGS_WATERMARK_TABLE_NAME, @@ -255,12 +251,6 @@ static const TableIndexDef catalog_table_index_definitions[_MAX_CATALOG_TABLES] .names = (char *[]) { [COMPRESSION_CHUNK_SIZE_PKEY] = "compression_chunk_size_pkey", }, - }, - [CONTINUOUS_AGGS_BUCKET_FUNCTION] = { - .length = _MAX_CONTINUOUS_AGGS_BUCKET_FUNCTION_INDEX, - .names = (char *[]) { - [CONTINUOUS_AGGS_BUCKET_FUNCTION_PKEY_IDX] = "continuous_aggs_bucket_function_pkey", - }, } }; diff --git a/src/ts_catalog/catalog.h b/src/ts_catalog/catalog.h index 36d925acef4..7be84f27dd2 100644 --- a/src/ts_catalog/catalog.h +++ b/src/ts_catalog/catalog.h @@ -50,7 +50,6 @@ typedef enum CatalogTable CONTINUOUS_AGGS_MATERIALIZATION_INVALIDATION_LOG, COMPRESSION_SETTINGS, COMPRESSION_CHUNK_SIZE, - CONTINUOUS_AGGS_BUCKET_FUNCTION, CONTINUOUS_AGGS_WATERMARK, TELEMETRY_EVENT, CHUNK_COLUMN_STATS, @@ -972,38 +971,6 @@ typedef enum Anum_continuous_agg_raw_hypertable_id_idx #define Natts_continuous_agg_raw_hypertable_id_idx \ (_Anum_continuous_agg_raw_hypertable_id_idx_max - 1) -/*** continuous_aggs_bucket_function table definitions ***/ - -#define CONTINUOUS_AGGS_BUCKET_FUNCTION_TABLE_NAME "continuous_aggs_bucket_function" -typedef enum Anum_continuous_aggs_bucket_function -{ - Anum_continuous_aggs_bucket_function_mat_hypertable_id = 1, - Anum_continuous_aggs_bucket_function_function, - Anum_continuous_aggs_bucket_function_bucket_width, - Anum_continuous_aggs_bucket_function_bucket_origin, - Anum_continuous_aggs_bucket_function_bucket_offset, - Anum_continuous_aggs_bucket_function_bucket_timezone, - Anum_continuous_aggs_bucket_function_bucket_fixed_width, - _Anum_continuous_aggs_bucket_function_max, -} Anum_continuous_aggs_bucket_function; - -#define Natts_continuous_aggs_bucket_function (_Anum_continuous_aggs_bucket_function_max - 1) - -enum -{ - CONTINUOUS_AGGS_BUCKET_FUNCTION_PKEY_IDX = 0, - _MAX_CONTINUOUS_AGGS_BUCKET_FUNCTION_INDEX, -}; - -typedef enum Anum_continuous_aggs_bucket_function_pkey -{ - Anum_continuous_aggs_bucket_function_pkey_mat_hypertable_id = 1, - _Anum_continuous_aggs_bucket_function_pkey_max, -} Anum_continuous_aggs_bucket_function_pkey; - -#define Natts_continuous_aggs_bucket_function_pkey \ - (_Anum_continuous_aggs_bucket_function_pkey_max - 1) - /****** CONTINUOUS_AGGS_HYPERTABLE_INVALIDATION_LOG_TABLE definitions*/ #define CONTINUOUS_AGGS_HYPERTABLE_INVALIDATION_LOG_TABLE_NAME \ "continuous_aggs_hypertable_invalidation_log" diff --git a/src/ts_catalog/continuous_agg.c b/src/ts_catalog/continuous_agg.c index a786b4bf44a..1eb44bdd298 100644 --- a/src/ts_catalog/continuous_agg.c +++ b/src/ts_catalog/continuous_agg.c @@ -46,6 +46,8 @@ #define BUCKET_FUNCTION_SERIALIZE_VERSION 1 #define CHECK_NAME_MATCH(name1, name2) (namestrcmp(name1, name2) == 0) +static ObjectAddress get_and_lock_rel_by_name(const Name schema, const Name name, LOCKMODE mode); + static const WithClauseDefinition continuous_aggregate_with_clause_def[] = { [ContinuousEnabled] = { .arg_names = {"continuous", NULL}, @@ -149,21 +151,6 @@ init_scan_by_mat_hypertable_id(ScanIterator *iterator, const int32 mat_hypertabl Int32GetDatum(mat_hypertable_id)); } -static void -init_scan_cagg_bucket_function_by_mat_hypertable_id(ScanIterator *iterator, - const int32 mat_hypertable_id) -{ - iterator->ctx.index = catalog_get_index(ts_catalog_get(), - CONTINUOUS_AGGS_BUCKET_FUNCTION, - CONTINUOUS_AGGS_BUCKET_FUNCTION_PKEY_IDX); - - ts_scan_iterator_scan_key_init(iterator, - Anum_continuous_aggs_bucket_function_pkey_mat_hypertable_id, - BTEqualStrategyNumber, - F_INT4EQ, - Int32GetDatum(mat_hypertable_id)); -} - static void init_scan_by_raw_hypertable_id(ScanIterator *iterator, const int32 raw_hypertable_id) { @@ -252,22 +239,6 @@ invalidation_threshold_delete(int32 raw_hypertable_id) } } -static void -cagg_bucket_function_delete(int32 mat_hypertable_id) -{ - ScanIterator iterator = ts_scan_iterator_create(CONTINUOUS_AGGS_BUCKET_FUNCTION, - RowExclusiveLock, - CurrentMemoryContext); - - init_scan_cagg_bucket_function_by_mat_hypertable_id(&iterator, mat_hypertable_id); - - ts_scanner_foreach(&iterator) - { - TupleInfo *ti = ts_scan_iterator_tuple_info(&iterator); - ts_catalog_delete_tid(ti->scanrel, ts_scanner_get_tuple_tid(ti)); - } -} - static void hypertable_invalidation_log_delete(int32 raw_hypertable_id) { @@ -396,156 +367,6 @@ continuous_agg_formdata_fill(FormData_continuous_agg *fd, const TupleInfo *ti) heap_freetuple(tuple); } -/* - * Fill the fields of a integer based bucketing function - */ -static void -cagg_fill_bucket_function_integer_based(ContinuousAggsBucketFunction *bf, bool *isnull, - Datum *values) -{ - /* Bucket width */ - Assert(!isnull[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_width)]); - const char *bucket_width_str = TextDatumGetCString( - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_width)]); - Assert(strlen(bucket_width_str) > 0); - bf->bucket_integer_width = pg_strtoint64(bucket_width_str); - - /* Bucket origin cannot be used with integer based buckets */ - Assert(isnull[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_origin)] == - true); - - /* Bucket offset */ - if (!isnull[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_offset)]) - { - const char *offset_str = TextDatumGetCString( - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_offset)]); - bf->bucket_integer_offset = pg_strtoint64(offset_str); - } - - /* Timezones cannot be used with integer based buckets */ - Assert(isnull[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_timezone)] == - true); -} - -/* - * Fill the fields of a time based bucketing function - */ -static void -cagg_fill_bucket_function_time_based(ContinuousAggsBucketFunction *bf, bool *isnull, Datum *values) -{ - /* - * bucket_width - * - * The value is stored as TEXT since we have to store the interval value of time - * buckets and also the number value of integer based buckets. - */ - Assert(!isnull[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_width)]); - const char *bucket_width_str = TextDatumGetCString( - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_width)]); - Assert(strlen(bucket_width_str) > 0); - bf->bucket_time_width = DatumGetIntervalP( - DirectFunctionCall3(interval_in, CStringGetDatum(bucket_width_str), InvalidOid, -1)); - - /* Bucket origin */ - if (!isnull[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_origin)]) - { - const char *origin_str = TextDatumGetCString( - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_origin)]); - bf->bucket_time_origin = DatumGetTimestamp(DirectFunctionCall3(timestamptz_in, - CStringGetDatum(origin_str), - ObjectIdGetDatum(InvalidOid), - Int32GetDatum(-1))); - } - else - { - TIMESTAMP_NOBEGIN(bf->bucket_time_origin); - } - - /* Bucket offset */ - if (!isnull[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_offset)]) - { - const char *offset_str = TextDatumGetCString( - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_offset)]); - bf->bucket_time_offset = DatumGetIntervalP( - DirectFunctionCall3(interval_in, CStringGetDatum(offset_str), InvalidOid, -1)); - } - - /* Bucket timezone */ - if (!isnull[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_timezone)]) - { - bf->bucket_time_timezone = TextDatumGetCString( - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_timezone)]); - } -} - -static void -continuous_agg_fill_bucket_function(int32 mat_hypertable_id, ContinuousAggsBucketFunction *bf) -{ - ScanIterator iterator; - int count = 0; - - iterator = ts_scan_iterator_create(CONTINUOUS_AGGS_BUCKET_FUNCTION, - AccessShareLock, - CurrentMemoryContext); - init_scan_cagg_bucket_function_by_mat_hypertable_id(&iterator, mat_hypertable_id); - ts_scanner_foreach(&iterator) - { - Datum values[Natts_continuous_aggs_bucket_function]; - bool isnull[Natts_continuous_aggs_bucket_function]; - bool should_free; - - HeapTuple tuple = ts_scan_iterator_fetch_heap_tuple(&iterator, false, &should_free); - - /* - * Our usual GETSTRUCT() approach doesn't work when TEXT fields are involved, - * thus a more robust approach with heap_deform_tuple() is used here. - */ - heap_deform_tuple(tuple, ts_scan_iterator_tupledesc(&iterator), values, isnull); - - /* Bucket function */ - Assert(!isnull[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_function)]); - const char *bucket_function_str = TextDatumGetCString( - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_function)]); - bf->bucket_function = DatumGetObjectId( - DirectFunctionCall1(regprocedurein, CStringGetDatum(bucket_function_str))); - - bf->bucket_time_based = ts_continuous_agg_bucket_on_interval(bf->bucket_function); - - if (bf->bucket_time_based) - { - cagg_fill_bucket_function_time_based(bf, isnull, values); - } - else - { - cagg_fill_bucket_function_integer_based(bf, isnull, values); - } - - /* Bucket fixed width */ - Assert(!isnull[AttrNumberGetAttrOffset( - Anum_continuous_aggs_bucket_function_bucket_fixed_width)]); - bf->bucket_fixed_interval = DatumGetBool(values[AttrNumberGetAttrOffset( - Anum_continuous_aggs_bucket_function_bucket_fixed_width)]); - - count++; - - if (should_free) - heap_freetuple(tuple); - } - - /* - * This function should never be called unless we know that the corresponding - * cagg exists and uses a variable-sized bucket. There should be exactly one - * entry in .continuous_aggs_bucket_function catalog table for such a cagg. - */ - if (count != 1) - { - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("invalid or missing information about the bucketing function for cagg"), - errdetail("%d", mat_hypertable_id))); - } -} - static void continuous_agg_init(ContinuousAgg *cagg, const Form_continuous_agg fd) { @@ -563,8 +384,12 @@ continuous_agg_init(ContinuousAgg *cagg, const Form_continuous_agg fd) Assert(OidIsValid(cagg->relid)); Assert(OidIsValid(cagg->partition_type)); - cagg->bucket_function = palloc0(sizeof(ContinuousAggsBucketFunction)); - continuous_agg_fill_bucket_function(cagg->data.mat_hypertable_id, cagg->bucket_function); + ObjectAddress partial_view = + get_and_lock_rel_by_name(&fd->partial_view_schema, &fd->partial_view_name, AccessShareLock); + Assert(OidIsValid(partial_view.objectId)); + + cagg->bucket_function = + ts_cm_functions->continuous_agg_get_bucket_function_info_internal(partial_view.objectId); } TSDLLEXPORT CaggsInfo @@ -1004,8 +829,6 @@ drop_continuous_agg(FormData_continuous_agg *cadata, bool drop_user_view) ts_cagg_watermark_delete_by_mat_hypertable_id(form.mat_hypertable_id); } - cagg_bucket_function_delete(cadata->mat_hypertable_id); - /* Perform actual deletions now */ if (OidIsValid(user_view.objectId)) performDeletion(&user_view, DROP_RESTRICT, 0); diff --git a/src/ts_catalog/continuous_agg.h b/src/ts_catalog/continuous_agg.h index 268c42488d3..a55a2780ae9 100644 --- a/src/ts_catalog/continuous_agg.h +++ b/src/ts_catalog/continuous_agg.h @@ -77,14 +77,7 @@ ts_continuous_agg_get_compression_defelems(const WithClauseResult *with_clauses) */ typedef struct ContinuousAggsBucketFunction { - /* Oid of the bucketing function. In the catalog table, the regprocedure is used. This ensures - * that the Oid is mapped to a string when a backup is taken and the string is converted back to - * the Oid when the backup is restored. This way, we can use an Oid in the catalog table even - * when a backup is restored and the Oid may have changed. However, the dependency management in - * PostgreSQL does not track the Oid. If the function is dropped and a new one is created, the - * Oid changes and this value points to a non-existing Oid. This can not happen in real-world - * situations since PostgreSQL protects the bucket_function from deletion until the CAgg is - * defined. */ + /* Oid of the bucketing function */ Oid bucket_function; Oid bucket_width_type; /* type of bucket_width */ @@ -98,6 +91,7 @@ typedef struct ContinuousAggsBucketFunction * Fields that are used for time based buckets */ Interval *bucket_time_width; + /* * Custom origin value stored as UTC timestamp. * If not specified, stores infinity. diff --git a/test/expected/drop_rename_hypertable.out b/test/expected/drop_rename_hypertable.out index 005e018180d..f3e1debae7b 100644 --- a/test/expected/drop_rename_hypertable.out +++ b/test/expected/drop_rename_hypertable.out @@ -204,7 +204,6 @@ SELECT * FROM _timescaledb_catalog.hypertable; _timescaledb_catalog | continuous_agg | table | super_user _timescaledb_catalog | continuous_agg_migrate_plan | table | super_user _timescaledb_catalog | continuous_agg_migrate_plan_step | table | super_user - _timescaledb_catalog | continuous_aggs_bucket_function | table | super_user _timescaledb_catalog | continuous_aggs_hypertable_invalidation_log | table | super_user _timescaledb_catalog | continuous_aggs_invalidation_threshold | table | super_user _timescaledb_catalog | continuous_aggs_materialization_invalidation_log | table | super_user @@ -215,7 +214,7 @@ SELECT * FROM _timescaledb_catalog.hypertable; _timescaledb_catalog | metadata | table | super_user _timescaledb_catalog | tablespace | table | super_user _timescaledb_catalog | telemetry_event | table | super_user -(21 rows) +(20 rows) \dt "_timescaledb_internal".* List of relations diff --git a/tsl/src/continuous_aggs/common.c b/tsl/src/continuous_aggs/common.c index 50b1b849164..5b39c61465e 100644 --- a/tsl/src/continuous_aggs/common.c +++ b/tsl/src/continuous_aggs/common.c @@ -17,7 +17,8 @@ static void caggtimebucketinfo_init(CAggTimebucketInfo *src, int32 hypertable_id Oid hypertable_partition_coltype, int64 hypertable_partition_col_interval, int32 parent_mat_hypertable_id); -static void process_additional_timebucket_parameter(ContinuousAggsBucketFunction *bf, Const *arg); +static void process_additional_timebucket_parameter(ContinuousAggsBucketFunction *bf, Const *arg, + bool *custom_origin); static void process_timebucket_parameters(FuncExpr *fe, ContinuousAggsBucketFunction *bf, bool process_checks, bool is_cagg_create, AttrNumber htpartcolno); @@ -181,7 +182,8 @@ destroy_union_query(Query *q) * Handle additional parameter of the timebucket function such as timezone, offset, or origin */ static void -process_additional_timebucket_parameter(ContinuousAggsBucketFunction *bf, Const *arg) +process_additional_timebucket_parameter(ContinuousAggsBucketFunction *bf, Const *arg, + bool *custom_origin) { char *tz_name; switch (exprType((Node *) arg)) @@ -204,16 +206,20 @@ process_additional_timebucket_parameter(ContinuousAggsBucketFunction *bf, Const break; case DATEOID: /* Bucket origin as Date */ - bf->bucket_time_origin = - date2timestamptz_opt_overflow(DatumGetDateADT(arg->constvalue), NULL); + if (!arg->constisnull) + bf->bucket_time_origin = + date2timestamptz_opt_overflow(DatumGetDateADT(arg->constvalue), NULL); + *custom_origin = true; break; case TIMESTAMPOID: /* Bucket origin as Timestamp */ bf->bucket_time_origin = DatumGetTimestamp(arg->constvalue); + *custom_origin = true; break; case TIMESTAMPTZOID: /* Bucket origin as TimestampTZ */ bf->bucket_time_origin = DatumGetTimestampTz(arg->constvalue); + *custom_origin = true; break; case INT2OID: /* Bucket offset as smallint */ @@ -248,10 +254,12 @@ process_timebucket_parameters(FuncExpr *fe, ContinuousAggsBucketFunction *bf, bo Node *width_arg; Node *col_arg; bool custom_origin = false; - Const *const_arg; + TIMESTAMP_NOBEGIN(bf->bucket_time_origin); + int nargs; /* Only column allowed : time_bucket('1day', ) */ col_arg = lsecond(fe->args); + /* Could be a named argument */ if (IsA(col_arg, NamedArgExpr)) col_arg = (Node *) castNode(NamedArgExpr, col_arg)->arg; @@ -263,75 +271,52 @@ process_timebucket_parameters(FuncExpr *fe, ContinuousAggsBucketFunction *bf, bo errmsg("time bucket function must reference the primary hypertable " "dimension column"))); - if (list_length(fe->args) >= 3) + nargs = list_length(fe->args); + Assert(nargs >= 2 && nargs <= 5); + + /* + * Process the third argument of the time bucket function. This could be `timezone`, `offset`, + * or `origin`. + * + * Time bucket function variations with 3 and 5 arguments: + * - time_bucket(width SMALLINT, ts SMALLINT, offset SMALLINT) + * - time_bucket(width INTEGER, ts INTEGER, offset INTEGER) + * - time_bucket(width BIGINT, ts BIGINT, offset BIGINT) + * - time_bucket(width INTERVAL, ts DATE, offset INTERVAL) + * - time_bucket(width INTERVAL, ts DATE, origin DATE) + * - time_bucket(width INTERVAL, ts TIMESTAMPTZ, offset INTERVAL) + * - time_bucket(width INTERVAL, ts TIMESTAMPTZ, origin TIMESTAMPTZ) + * - time_bucket(width INTERVAL, ts TIMESTAMPTZ, timezone TEXT, origin TIMESTAMPTZ, + * offset INTERVAL) + * - time_bucket(width INTERVAL, ts TIMESTAMP, offset INTERVAL) + * - time_bucket(width INTERVAL, ts TIMESTAMP, origin TIMESTAMP) + */ + if (nargs >= 3) { Const *arg = check_time_bucket_argument(lthird(fe->args), "third", process_checks); - process_additional_timebucket_parameter(bf, arg); + process_additional_timebucket_parameter(bf, arg, &custom_origin); } - if (list_length(fe->args) >= 4) + /* + * Process the fourth and fifth arguments of the time bucket function. This could be `origin` or + * `offset`. + * + * Time bucket function variation with 5 arguments: + * - time_bucket(width INTERVAL, ts TIMESTAMPTZ, timezone TEXT, origin TIMESTAMPTZ, + * offset INTERVAL) + */ + if (nargs >= 4) { Const *arg = check_time_bucket_argument(lfourth(fe->args), "fourth", process_checks); - process_additional_timebucket_parameter(bf, arg); + process_additional_timebucket_parameter(bf, arg, &custom_origin); } - /* Check for custom origin. */ - switch (exprType(col_arg)) + if (nargs == 5) { - case DATEOID: - /* Origin is always 3rd arg for date variants. */ - if (list_length(fe->args) == 3 && exprType(lthird(fe->args)) == DATEOID) - { - Node *arg = lthird(fe->args); - custom_origin = true; - /* this function also takes care of named arguments */ - const_arg = check_time_bucket_argument(arg, "third", process_checks); - bf->bucket_time_origin = - DatumGetTimestamp(DirectFunctionCall1(date_timestamp, const_arg->constvalue)); - } - break; - case TIMESTAMPOID: - /* Origin is always 3rd arg for timestamp variants. */ - if (list_length(fe->args) == 3 && exprType(lthird(fe->args)) == TIMESTAMPOID) - { - Node *arg = lthird(fe->args); - custom_origin = true; - const_arg = check_time_bucket_argument(arg, "third", process_checks); - bf->bucket_time_origin = DatumGetTimestamp(const_arg->constvalue); - } - break; - case TIMESTAMPTZOID: - /* Origin can be 3rd or 4th arg for timestamptz variants. */ - if (list_length(fe->args) >= 3 && exprType(lthird(fe->args)) == TIMESTAMPTZOID) - { - Node *arg = lthird(fe->args); - custom_origin = true; - Const *constval = check_time_bucket_argument(arg, "third", process_checks); - bf->bucket_time_origin = DatumGetTimestampTz(constval->constvalue); - } - else if (list_length(fe->args) >= 4 && exprType(lfourth(fe->args)) == TIMESTAMPTZOID) - { - custom_origin = true; - if (IsA(lfourth(fe->args), Const)) - { - bf->bucket_time_origin = - DatumGetTimestampTz(castNode(Const, lfourth(fe->args))->constvalue); - } - /* could happen in a statement like time_bucket('1h', .., 'utc', origin => - * ...) */ - else if (IsA(lfourth(fe->args), NamedArgExpr)) - { - Const *constval = - check_time_bucket_argument(lfourth(fe->args), "fourth", process_checks); - - bf->bucket_time_origin = DatumGetTimestampTz(constval->constvalue); - } - } - break; - default: - /* Nothing to do for integer time column. */ - break; + Const *arg = check_time_bucket_argument(lfifth(fe->args), "fifth", process_checks); + process_additional_timebucket_parameter(bf, arg, &custom_origin); } + if (process_checks && custom_origin && TIMESTAMP_NOT_FINITE(bf->bucket_time_origin)) { ereport(ERROR, @@ -1502,11 +1487,11 @@ cagg_get_by_relid_or_fail(const Oid cagg_relid) /* Get time bucket function info based on the view definition */ ContinuousAggsBucketFunction * -ts_cagg_get_bucket_function_info(Oid view_oid) +tsl_cagg_get_bucket_function_info(Oid view_oid) { - Relation view_rel = relation_open(view_oid, AccessShareLock); + Relation view_rel = table_open(view_oid, AccessShareLock); Query *query = copyObject(get_view_query(view_rel)); - relation_close(view_rel, NoLock); + table_close(view_rel, NoLock); Assert(query != NULL); Assert(query->commandType == CMD_SELECT); diff --git a/tsl/src/continuous_aggs/common.h b/tsl/src/continuous_aggs/common.h index 6051e0de7d4..94f7570155e 100644 --- a/tsl/src/continuous_aggs/common.h +++ b/tsl/src/continuous_aggs/common.h @@ -140,4 +140,4 @@ cagg_get_time_min(const ContinuousAgg *cagg) return ts_time_get_min(cagg->partition_type); } -ContinuousAggsBucketFunction *ts_cagg_get_bucket_function_info(Oid view_oid); +extern ContinuousAggsBucketFunction *tsl_cagg_get_bucket_function_info(Oid view_oid); diff --git a/tsl/src/continuous_aggs/create.c b/tsl/src/continuous_aggs/create.c index f290cd38956..587065007ea 100644 --- a/tsl/src/continuous_aggs/create.c +++ b/tsl/src/continuous_aggs/create.c @@ -81,10 +81,6 @@ static void create_cagg_catalog_entry(int32 matht_id, int32 rawht_id, const char const char *partial_view, bool materialized_only, const char *direct_schema, const char *direct_view, const bool finalized, const int32 parent_mat_hypertable_id); -static void create_bucket_function_catalog_entry(int32 matht_id, Oid bucket_function, - const char *bucket_width, const char *origin, - const char *offset, const char *timezone, - const bool bucket_fixed_width); static void cagg_create_hypertable(int32 hypertable_id, Oid mat_tbloid, const char *matpartcolname, int64 mat_tbltimecol_interval); static void cagg_add_trigger_hypertable(Oid relid, int32 hypertable_id); @@ -177,86 +173,6 @@ create_cagg_catalog_entry(int32 matht_id, int32 rawht_id, const char *user_schem table_close(rel, RowExclusiveLock); } -/* - * Create a entry for the materialization table in table - * CONTINUOUS_AGGS_BUCKET_FUNCTION. - */ -static void -create_bucket_function_catalog_entry(int32 matht_id, Oid bucket_function, const char *bucket_width, - const char *bucket_origin, const char *bucket_offset, - const char *bucket_timezone, const bool bucket_fixed_width) -{ - Catalog *catalog = ts_catalog_get(); - Relation rel; - TupleDesc desc; - Datum values[Natts_continuous_aggs_bucket_function]; - bool nulls[Natts_continuous_aggs_bucket_function] = { false }; - CatalogSecurityContext sec_ctx; - - Assert(OidIsValid(bucket_function)); - Assert(bucket_width != NULL); - - rel = table_open(catalog_get_table_id(catalog, CONTINUOUS_AGGS_BUCKET_FUNCTION), - RowExclusiveLock); - desc = RelationGetDescr(rel); - - memset(values, 0, sizeof(values)); - - /* Hypertable ID */ - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_mat_hypertable_id)] = - matht_id; - - /* Bucket function */ - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_function)] = - CStringGetTextDatum(format_procedure_qualified(bucket_function)); - - /* Bucket width */ - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_width)] = - CStringGetTextDatum(bucket_width); - - /* Bucket origin */ - if (bucket_origin != NULL) - { - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_origin)] = - CStringGetTextDatum(bucket_origin); - } - else - { - nulls[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_origin)] = true; - } - - /* Bucket offset */ - if (bucket_offset != NULL) - { - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_offset)] = - CStringGetTextDatum(bucket_offset); - } - else - { - nulls[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_offset)] = true; - } - - /* Bucket timezone */ - if (bucket_timezone != NULL) - { - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_timezone)] = - CStringGetTextDatum(bucket_timezone); - } - else - { - nulls[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_timezone)] = true; - } - - /* Bucket fixed width */ - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_fixed_width)] = - BoolGetDatum(bucket_fixed_width); - - ts_catalog_database_info_become_owner(ts_catalog_database_info_get(), &sec_ctx); - ts_catalog_insert_values(rel, desc, values, nulls); - ts_catalog_restore_user(&sec_ctx); - table_close(rel, RowExclusiveLock); -} - /* * Create hypertable for the table referred by mat_tbloid * matpartcolname - partition column for hypertable @@ -815,14 +731,6 @@ cagg_create(const CreateTableAsStmt *create_stmt, ViewStmt *stmt, Query *panquer } } - create_bucket_function_catalog_entry(materialize_hypertable_id, - bucket_info->bf->bucket_function, - bucket_width, - bucket_origin, - bucket_offset, - bucket_info->bf->bucket_time_timezone, - bucket_info->bf->bucket_fixed_interval); - /* Step 5: Create trigger on raw hypertable -specified in the user view query. */ cagg_add_trigger_hypertable(bucket_info->htoid, bucket_info->htid); } diff --git a/tsl/src/continuous_aggs/utils.c b/tsl/src/continuous_aggs/utils.c index 6b9771c3162..468198bc79f 100644 --- a/tsl/src/continuous_aggs/utils.c +++ b/tsl/src/continuous_aggs/utils.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -292,88 +291,6 @@ get_replacement_timebucket_function(const ContinuousAgg *cagg, bool *need_parame return funcid; } -/* - * Update the cagg bucket function catalog table. During the migration, we set a new bucket - * function and a origin if the bucket function is time based. - */ -static ScanTupleResult -cagg_time_bucket_update(TupleInfo *ti, void *data) -{ - bool should_free; - HeapTuple tuple = ts_scanner_fetch_heap_tuple(ti, false, &should_free); - TupleDesc tupleDesc = ts_scanner_get_tupledesc(ti); - const ContinuousAgg *cagg = (ContinuousAgg *) data; - - Datum values[Natts_continuous_aggs_bucket_function] = { 0 }; - bool isnull[Natts_continuous_aggs_bucket_function] = { 0 }; - bool doReplace[Natts_continuous_aggs_bucket_function] = { 0 }; - - /* Update the bucket function */ - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_function)] = - CStringGetTextDatum(format_procedure_qualified(cagg->bucket_function->bucket_function)); - doReplace[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_function)] = true; - - /* Set new origin if not already present. Time_bucket and time_bucket_ng use different - * origin values for time based values. - */ - if (cagg->bucket_function->bucket_time_based) - { - char *origin_value = DatumGetCString( - DirectFunctionCall1(timestamptz_out, - TimestampTzGetDatum(cagg->bucket_function->bucket_time_origin))); - - values[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_origin)] = - CStringGetTextDatum(origin_value); - - doReplace[AttrNumberGetAttrOffset(Anum_continuous_aggs_bucket_function_bucket_origin)] = - true; - } - - HeapTuple new_tuple = heap_modify_tuple(tuple, tupleDesc, values, isnull, doReplace); - - ts_catalog_update(ti->scanrel, new_tuple); - - heap_freetuple(new_tuple); - - if (should_free) - heap_freetuple(tuple); - - return SCAN_DONE; -} - -/* - * Search for the bucket function entry in the catalog and update the values. - */ -static int -replace_time_bucket_function_in_catalog(ContinuousAgg *cagg) -{ - ScanKeyData scankey[1]; - - ScanKeyInit(&scankey[0], - Anum_continuous_aggs_bucket_function_pkey_mat_hypertable_id, - BTEqualStrategyNumber, - F_INT4EQ, - Int32GetDatum(cagg->data.mat_hypertable_id)); - - Catalog *catalog = ts_catalog_get(); - - ScannerCtx scanctx = { - .table = catalog_get_table_id(catalog, CONTINUOUS_AGGS_BUCKET_FUNCTION), - .index = catalog_get_index(catalog, - CONTINUOUS_AGGS_BUCKET_FUNCTION, - CONTINUOUS_AGGS_BUCKET_FUNCTION_PKEY_IDX), - .nkeys = 1, - .scankey = scankey, - .data = cagg, - .limit = 1, - .tuple_found = cagg_time_bucket_update, - .lockmode = AccessShareLock, - .scandirection = ForwardScanDirection, - }; - - return ts_scanner_scan(&scanctx); -} - typedef struct TimeBucketInfoContext { /* The updated cagg definition */ @@ -385,6 +302,7 @@ typedef struct TimeBucketInfoContext /* Was the defined origin added during the migration and needs * to be added to the function parameters during rewrite? */ bool origin_added_during_migration; + TimestampTz bucket_time_origin_to_replace; /* Do we need to flip the timezone and the origin parameter during migration? */ bool need_parameter_order_change; @@ -401,19 +319,17 @@ build_const_value_for_origin(TimeBucketInfoContext *context, Oid origin_type) switch (origin_type) { case TIMESTAMPTZOID: - const_datum = TimestampTzGetDatum(context->cagg->bucket_function->bucket_time_origin); + const_datum = TimestampTzGetDatum(context->bucket_time_origin_to_replace); break; case TIMESTAMPOID: const_datum = DirectFunctionCall1(timestamptz_timestamp, - TimestampTzGetDatum( - context->cagg->bucket_function->bucket_time_origin)); + TimestampTzGetDatum(context->bucket_time_origin_to_replace)); break; case DATEOID: const_datum = DirectFunctionCall1(timestamptz_date, - TimestampTzGetDatum( - context->cagg->bucket_function->bucket_time_origin)); + TimestampTzGetDatum(context->bucket_time_origin_to_replace)); break; default: elog(ERROR, @@ -512,7 +428,7 @@ cagg_user_query_mutator(Node *node, TimeBucketInfoContext *context) * Rewrite the given CAgg view and replace the bucket function */ static void -continuous_agg_rewrite_view(Oid view_oid, const ContinuousAgg *cagg, TimeBucketInfoContext *context) +continuous_agg_rewrite_view(Oid view_oid, TimeBucketInfoContext *context) { int sec_ctx; Oid uid, saved_uid; @@ -529,7 +445,7 @@ continuous_agg_rewrite_view(Oid view_oid, const ContinuousAgg *cagg, TimeBucketI Query *updated_direct_query = (Query *) cagg_user_query_mutator((Node *) direct_query, context); /* Store updated CAgg query */ - SWITCH_TO_TS_USER(NameStr(cagg->data.user_view_schema), uid, saved_uid, sec_ctx); + SWITCH_TO_TS_USER(NameStr(context->cagg->data.user_view_schema), uid, saved_uid, sec_ctx); StoreViewQuery(view_oid, updated_direct_query, true); CommandCounterIncrement(); RESTORE_USER(uid, saved_uid, sec_ctx); @@ -539,29 +455,32 @@ continuous_agg_rewrite_view(Oid view_oid, const ContinuousAgg *cagg, TimeBucketI * Replace the bucket function in the CAgg view definition */ static void -continuous_agg_replace_function(const ContinuousAgg *cagg, Oid function_to_replace, +continuous_agg_replace_function(ContinuousAgg *cagg, Oid function_to_replace, bool origin_added_during_migration, + TimestampTz bucket_time_origin_to_replace, bool need_parameter_order_change) { - TimeBucketInfoContext context = { 0 }; - context.cagg = cagg; - context.function_to_replace = function_to_replace; - context.origin_added_during_migration = origin_added_during_migration; - context.need_parameter_order_change = need_parameter_order_change; + TimeBucketInfoContext context = { .cagg = cagg, + .function_to_replace = function_to_replace, + .origin_added_during_migration = + origin_added_during_migration, + .bucket_time_origin_to_replace = + bucket_time_origin_to_replace, + .need_parameter_order_change = need_parameter_order_change }; /* Rewrite the direct_view */ Oid direct_view_oid = ts_get_relation_relid(NameStr(cagg->data.direct_view_schema), NameStr(cagg->data.direct_view_name), false); - continuous_agg_rewrite_view(direct_view_oid, cagg, &context); + continuous_agg_rewrite_view(direct_view_oid, &context); /* Rewrite the partial_view */ Oid partial_view_oid = ts_get_relation_relid(NameStr(cagg->data.partial_view_schema), NameStr(cagg->data.partial_view_name), false); - continuous_agg_rewrite_view(partial_view_oid, cagg, &context); + continuous_agg_rewrite_view(partial_view_oid, &context); /* Rewrite the user facing view if needed */ if (!cagg->data.materialized_only) @@ -570,7 +489,7 @@ continuous_agg_replace_function(const ContinuousAgg *cagg, Oid function_to_repla NameStr(cagg->data.user_view_name), false); - continuous_agg_rewrite_view(user_view_oid, cagg, &context); + continuous_agg_rewrite_view(user_view_oid, &context); } } @@ -578,12 +497,12 @@ continuous_agg_replace_function(const ContinuousAgg *cagg, Oid function_to_repla * Get the default origin value for time_bucket to be compatible with * the default origin of time_bucket_ng. */ -static TimestampTz -continuous_agg_get_default_origin(Oid new_bucket_function) +TimestampTz +continuous_agg_get_default_origin(Oid bucket_function) { - Assert(OidIsValid(new_bucket_function)); + Assert(OidIsValid(bucket_function)); - Oid bucket_function_rettype = get_func_rettype(new_bucket_function); + Oid bucket_function_rettype = get_func_rettype(bucket_function); Assert(OidIsValid(bucket_function_rettype)); Datum origin; @@ -684,13 +603,18 @@ continuous_agg_migrate_to_time_bucket(PG_FUNCTION_ARGS) if (cagg->bucket_function->bucket_time_based && TIMESTAMP_NOT_FINITE(cagg->bucket_function->bucket_time_origin)) { - cagg->bucket_function->bucket_time_origin = - continuous_agg_get_default_origin(new_bucket_function); + cagg->bucket_function->bucket_time_origin = continuous_agg_get_default_origin(new_bucket_function);; origin_added_during_migration = true; } - /* Update the catalog */ - replace_time_bucket_function_in_catalog(cagg); + /* Modify the CAgg view definition */ + continuous_agg_replace_function(cagg, + old_bucket_function, + origin_added_during_migration, + cagg->bucket_function->bucket_time_origin, + need_parameter_order_change); + + CommandCounterIncrement(); /* Fetch new CAgg definition from catalog */ ContinuousAgg PG_USED_FOR_ASSERTS_ONLY *new_cagg_definition = @@ -699,12 +623,6 @@ continuous_agg_migrate_to_time_bucket(PG_FUNCTION_ARGS) Assert(cagg->bucket_function->bucket_time_origin == new_cagg_definition->bucket_function->bucket_time_origin); - /* Modify the CAgg view definition */ - continuous_agg_replace_function(cagg, - old_bucket_function, - origin_added_during_migration, - need_parameter_order_change); - /* The migration is a procedure, no return value is expected */ PG_RETURN_VOID(); } @@ -892,7 +810,7 @@ cagg_get_bucket_function_datum(int32 mat_hypertable_id, FunctionCallInfo fcinfo) if (fcinfo != NULL && get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) elog(ERROR, "function returning record called in context that cannot accept type record"); - ContinuousAggsBucketFunction *bf = ts_cagg_get_bucket_function_info(direct_view_oid); + ContinuousAggsBucketFunction *bf = tsl_cagg_get_bucket_function_info(direct_view_oid); if (!OidIsValid(bf->bucket_function)) { diff --git a/tsl/src/continuous_aggs/utils.h b/tsl/src/continuous_aggs/utils.h index 99292f4dba5..a0ed1e34b9a 100644 --- a/tsl/src/continuous_aggs/utils.h +++ b/tsl/src/continuous_aggs/utils.h @@ -19,3 +19,4 @@ extern Datum continuous_agg_validate_query(PG_FUNCTION_ARGS); extern Datum continuous_agg_migrate_to_time_bucket(PG_FUNCTION_ARGS); extern Datum continuous_agg_get_bucket_function(PG_FUNCTION_ARGS); extern Datum continuous_agg_get_bucket_function_info(PG_FUNCTION_ARGS); +extern TimestampTz continuous_agg_get_default_origin(Oid new_bucket_function); diff --git a/tsl/src/init.c b/tsl/src/init.c index 24f5c917515..3ef73d2897b 100644 --- a/tsl/src/init.c +++ b/tsl/src/init.c @@ -147,6 +147,7 @@ CrossModuleFunctions tsl_cm_functions = { .continuous_agg_validate_query = continuous_agg_validate_query, .continuous_agg_get_bucket_function = continuous_agg_get_bucket_function, .continuous_agg_get_bucket_function_info = continuous_agg_get_bucket_function_info, + .continuous_agg_get_bucket_function_info_internal = tsl_cagg_get_bucket_function_info, .continuous_agg_migrate_to_time_bucket = continuous_agg_migrate_to_time_bucket, .cagg_try_repair = tsl_cagg_try_repair, diff --git a/tsl/test/expected/cagg_bgw-16.out b/tsl/test/expected/cagg_bgw-16.out index 15abb5ea074..10a9839fca3 100644 --- a/tsl/test/expected/cagg_bgw-16.out +++ b/tsl/test/expected/cagg_bgw-16.out @@ -109,7 +109,7 @@ SELECT mat_hypertable_id, user_view_schema, user_view_name FROM _timescaledb_cat 2 | public | test_continuous_agg_view (1 row) -SELECT mat_hypertable_id, bucket_width FROM _timescaledb_catalog.continuous_aggs_bucket_function; +SELECT mat_hypertable_id, bucket_width FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id); mat_hypertable_id | bucket_width -------------------+-------------- 2 | 2 diff --git a/tsl/test/expected/cagg_bgw-17.out b/tsl/test/expected/cagg_bgw-17.out index 15abb5ea074..10a9839fca3 100644 --- a/tsl/test/expected/cagg_bgw-17.out +++ b/tsl/test/expected/cagg_bgw-17.out @@ -109,7 +109,7 @@ SELECT mat_hypertable_id, user_view_schema, user_view_name FROM _timescaledb_cat 2 | public | test_continuous_agg_view (1 row) -SELECT mat_hypertable_id, bucket_width FROM _timescaledb_catalog.continuous_aggs_bucket_function; +SELECT mat_hypertable_id, bucket_width FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id); mat_hypertable_id | bucket_width -------------------+-------------- 2 | 2 diff --git a/tsl/test/expected/cagg_migrate.out b/tsl/test/expected/cagg_migrate.out index 492303e1ff2..92c0c0dd197 100644 --- a/tsl/test/expected/cagg_migrate.out +++ b/tsl/test/expected/cagg_migrate.out @@ -159,7 +159,6 @@ UNION ALL COPY _timescaledb_catalog.hypertable (id, schema_name, table_name, associated_schema_name, associated_table_prefix, num_dimensions, chunk_sizing_func_schema, chunk_sizing_func_name, chunk_target_size, compression_state, compressed_hypertable_id, status) FROM stdin; COPY _timescaledb_catalog.dimension (id, hypertable_id, column_name, column_type, aligned, num_slices, partitioning_func_schema, partitioning_func, interval_length, compress_interval_length, integer_now_func_schema, integer_now_func) FROM stdin; COPY _timescaledb_catalog.continuous_agg (mat_hypertable_id, raw_hypertable_id, parent_mat_hypertable_id, user_view_schema, user_view_name, partial_view_schema, partial_view_name, direct_view_schema, direct_view_name, materialized_only, finalized) FROM stdin; -COPY _timescaledb_catalog.continuous_aggs_bucket_function (mat_hypertable_id, bucket_func, bucket_width, bucket_fixed_width) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_invalidation_threshold (hypertable_id, watermark) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_materialization_invalidation_log (materialization_id, lowest_modified_value, greatest_modified_value) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_watermark (mat_hypertable_id, watermark) FROM stdin; @@ -1028,7 +1027,6 @@ UNION ALL COPY _timescaledb_catalog.hypertable (id, schema_name, table_name, associated_schema_name, associated_table_prefix, num_dimensions, chunk_sizing_func_schema, chunk_sizing_func_name, chunk_target_size, compression_state, compressed_hypertable_id, status) FROM stdin; COPY _timescaledb_catalog.dimension (id, hypertable_id, column_name, column_type, aligned, num_slices, partitioning_func_schema, partitioning_func, interval_length, compress_interval_length, integer_now_func_schema, integer_now_func) FROM stdin; COPY _timescaledb_catalog.continuous_agg (mat_hypertable_id, raw_hypertable_id, parent_mat_hypertable_id, user_view_schema, user_view_name, partial_view_schema, partial_view_name, direct_view_schema, direct_view_name, materialized_only, finalized) FROM stdin; -COPY _timescaledb_catalog.continuous_aggs_bucket_function (mat_hypertable_id, bucket_func, bucket_width, bucket_fixed_width) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_invalidation_threshold (hypertable_id, watermark) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_materialization_invalidation_log (materialization_id, lowest_modified_value, greatest_modified_value) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_watermark (mat_hypertable_id, watermark) FROM stdin; @@ -1874,7 +1872,6 @@ UNION ALL COPY _timescaledb_catalog.hypertable (id, schema_name, table_name, associated_schema_name, associated_table_prefix, num_dimensions, chunk_sizing_func_schema, chunk_sizing_func_name, chunk_target_size, compression_state, compressed_hypertable_id, status) FROM stdin; COPY _timescaledb_catalog.dimension (id, hypertable_id, column_name, column_type, aligned, num_slices, partitioning_func_schema, partitioning_func, interval_length, compress_interval_length, integer_now_func_schema, integer_now_func) FROM stdin; COPY _timescaledb_catalog.continuous_agg (mat_hypertable_id, raw_hypertable_id, parent_mat_hypertable_id, user_view_schema, user_view_name, partial_view_schema, partial_view_name, direct_view_schema, direct_view_name, materialized_only, finalized) FROM stdin; -COPY _timescaledb_catalog.continuous_aggs_bucket_function (mat_hypertable_id, bucket_func, bucket_width, bucket_fixed_width) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_invalidation_threshold (hypertable_id, watermark) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_materialization_invalidation_log (materialization_id, lowest_modified_value, greatest_modified_value) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_watermark (mat_hypertable_id, watermark) FROM stdin; @@ -2710,7 +2707,6 @@ UNION ALL COPY _timescaledb_catalog.hypertable (id, schema_name, table_name, associated_schema_name, associated_table_prefix, num_dimensions, chunk_sizing_func_schema, chunk_sizing_func_name, chunk_target_size, compression_state, compressed_hypertable_id, status) FROM stdin; COPY _timescaledb_catalog.dimension (id, hypertable_id, column_name, column_type, aligned, num_slices, partitioning_func_schema, partitioning_func, interval_length, compress_interval_length, integer_now_func_schema, integer_now_func) FROM stdin; COPY _timescaledb_catalog.continuous_agg (mat_hypertable_id, raw_hypertable_id, parent_mat_hypertable_id, user_view_schema, user_view_name, partial_view_schema, partial_view_name, direct_view_schema, direct_view_name, materialized_only, finalized) FROM stdin; -COPY _timescaledb_catalog.continuous_aggs_bucket_function (mat_hypertable_id, bucket_func, bucket_width, bucket_fixed_width) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_invalidation_threshold (hypertable_id, watermark) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_materialization_invalidation_log (materialization_id, lowest_modified_value, greatest_modified_value) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_watermark (mat_hypertable_id, watermark) FROM stdin; @@ -2910,7 +2906,6 @@ UNION ALL COPY _timescaledb_catalog.hypertable (id, schema_name, table_name, associated_schema_name, associated_table_prefix, num_dimensions, chunk_sizing_func_schema, chunk_sizing_func_name, chunk_target_size, compression_state, compressed_hypertable_id, status) FROM stdin; COPY _timescaledb_catalog.dimension (id, hypertable_id, column_name, column_type, aligned, num_slices, partitioning_func_schema, partitioning_func, interval_length, compress_interval_length, integer_now_func_schema, integer_now_func) FROM stdin; COPY _timescaledb_catalog.continuous_agg (mat_hypertable_id, raw_hypertable_id, parent_mat_hypertable_id, user_view_schema, user_view_name, partial_view_schema, partial_view_name, direct_view_schema, direct_view_name, materialized_only, finalized) FROM stdin; -COPY _timescaledb_catalog.continuous_aggs_bucket_function (mat_hypertable_id, bucket_func, bucket_width, bucket_fixed_width) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_invalidation_threshold (hypertable_id, watermark) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_materialization_invalidation_log (materialization_id, lowest_modified_value, greatest_modified_value) FROM stdin; COPY _timescaledb_catalog.continuous_aggs_watermark (mat_hypertable_id, watermark) FROM stdin; diff --git a/tsl/test/expected/cagg_migrate_function-14.out b/tsl/test/expected/cagg_migrate_function-14.out index e9f4a249a3a..7b0dbbe87d7 100644 --- a/tsl/test/expected/cagg_migrate_function-14.out +++ b/tsl/test/expected/cagg_migrate_function-14.out @@ -170,7 +170,7 @@ SELECT mat_hypertable_id, SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-----------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + 5 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Sat Jan 04 00:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -206,7 +206,7 @@ CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + 5 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Sat Jan 04 00:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); diff --git a/tsl/test/expected/cagg_migrate_function-15.out b/tsl/test/expected/cagg_migrate_function-15.out index e9f4a249a3a..7b0dbbe87d7 100644 --- a/tsl/test/expected/cagg_migrate_function-15.out +++ b/tsl/test/expected/cagg_migrate_function-15.out @@ -170,7 +170,7 @@ SELECT mat_hypertable_id, SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-----------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + 5 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Sat Jan 04 00:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -206,7 +206,7 @@ CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + 5 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Sat Jan 04 00:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); diff --git a/tsl/test/expected/cagg_migrate_function-16.out b/tsl/test/expected/cagg_migrate_function-16.out index a030ec05aeb..6ee4679a965 100644 --- a/tsl/test/expected/cagg_migrate_function-16.out +++ b/tsl/test/expected/cagg_migrate_function-16.out @@ -170,7 +170,7 @@ SELECT mat_hypertable_id, SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-----------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + 5 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Sat Jan 04 00:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -206,7 +206,7 @@ CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + 5 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Sat Jan 04 00:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); diff --git a/tsl/test/expected/cagg_migrate_function-17.out b/tsl/test/expected/cagg_migrate_function-17.out index a030ec05aeb..6ee4679a965 100644 --- a/tsl/test/expected/cagg_migrate_function-17.out +++ b/tsl/test/expected/cagg_migrate_function-17.out @@ -170,7 +170,7 @@ SELECT mat_hypertable_id, SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-----------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + 5 | timescaledb_experimental.time_bucket_ng(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Sat Jan 04 00:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); @@ -206,7 +206,7 @@ CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; mat_hypertable_id | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - 5 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Fri Jan 03 16:00:00 2020 PST | | | t + 5 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 7 days | Sat Jan 04 00:00:00 2020 PST | | | t (1 row) SELECT pg_get_viewdef(:'partial_view', true); diff --git a/tsl/test/expected/cagg_query-14.out b/tsl/test/expected/cagg_query-14.out index 4739c69f52f..6d9eff93180 100644 --- a/tsl/test/expected/cagg_query-14.out +++ b/tsl/test/expected/cagg_query-14.out @@ -11,6 +11,7 @@ SET ROLE :ROLE_DEFAULT_PERM_USER; -- This file and its contents are licensed under the Timescale License. -- Please see the included NOTICE for copyright information and -- LICENSE-TIMESCALE for a copy of the license. +\set TEST_BASE_NAME cagg_query SELECT format('%s/results/%s_results_view.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW", format('%s/results/%s_results_view_hashagg.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW_HASHAGG", @@ -761,7 +762,7 @@ CREATE TABLE temperature_wo_tz ( value float ); SELECT create_hypertable('temperature_wo_tz', 'time'); -psql:include/cagg_query_common.sql:316: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices +psql:include/cagg_query_common.sql:317: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices create_hypertable -------------------------------- (5,public,temperature_wo_tz,t) @@ -793,21 +794,21 @@ CREATE TABLE table_bigint ( data bigint ); SELECT create_hypertable('table_smallint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:345: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" create_hypertable ----------------------------- (7,public,table_smallint,t) (1 row) SELECT create_hypertable('table_int', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" create_hypertable ------------------------ (8,public,table_int,t) (1 row) SELECT create_hypertable('table_bigint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:348: NOTICE: adding not-null constraint to column "time" create_hypertable --------------------------- (9,public,table_bigint,t) @@ -839,7 +840,7 @@ INSERT INTO table_int VALUES(1,2); INSERT INTO table_bigint VALUES(1,2); CREATE VIEW caggs_info AS SELECT user_view_schema, user_view_name, bucket_func, bucket_width, bucket_origin, bucket_offset, bucket_timezone, bucket_fixed_width -FROM _timescaledb_catalog.continuous_aggs_bucket_function NATURAL JOIN _timescaledb_catalog.continuous_agg; +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id); --- -- Tests with CAgg creation --- @@ -848,128 +849,128 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:372: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:373: NOTICE: refreshing continuous aggregate "cagg_4_hours" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours | public.time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours | time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours; -psql:include/cagg_query_common.sql:374: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk +psql:include/cagg_query_common.sql:375: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:380: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:381: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset; -psql:include/cagg_query_common.sql:382: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk +psql:include/cagg_query_common.sql:383: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:388: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" +psql:include/cagg_query_common.sql:389: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset2 | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset2 | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset2; -psql:include/cagg_query_common.sql:390: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk +psql:include/cagg_query_common.sql:391: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk -- Variable buckets (timezone is provided) with offset CREATE MATERIALIZED VIEW cagg_4_hours_offset_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:397: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" +psql:include/cagg_query_common.sql:398: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_ts; -psql:include/cagg_query_common.sql:399: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk +psql:include/cagg_query_common.sql:400: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:405: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:406: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin; -psql:include/cagg_query_common.sql:407: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk +psql:include/cagg_query_common.sql:408: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk -- Using named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:414: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" +psql:include/cagg_query_common.sql:415: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin2 | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin2 | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin2; -psql:include/cagg_query_common.sql:416: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk +psql:include/cagg_query_common.sql:417: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:423: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" +psql:include/cagg_query_common.sql:424: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts; -psql:include/cagg_query_common.sql:425: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk +psql:include/cagg_query_common.sql:426: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk -- Without named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, 'UTC', '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:432: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" +psql:include/cagg_query_common.sql:433: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts2; -psql:include/cagg_query_common.sql:434: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk +psql:include/cagg_query_common.sql:435: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk -- Timestamp based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:441: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" +psql:include/cagg_query_common.sql:442: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+----------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_wo_tz | public.time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+---------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_wo_tz | time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t (1 row) CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz @@ -977,169 +978,169 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:448: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" +psql:include/cagg_query_common.sql:449: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz; -psql:include/cagg_query_common.sql:450: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk +psql:include/cagg_query_common.sql:451: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:457: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" +psql:include/cagg_query_common.sql:458: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz2 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz2 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2; -psql:include/cagg_query_common.sql:459: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk +psql:include/cagg_query_common.sql:460: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:465: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" +psql:include/cagg_query_common.sql:466: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+-------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_wo_tz | public.time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_wo_tz | time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_wo_tz; -psql:include/cagg_query_common.sql:467: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk +psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk DROP MATERIALIZED VIEW cagg_4_hours_wo_tz; -psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk +psql:include/cagg_query_common.sql:469: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk -- Date based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_date WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:475: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" +psql:include/cagg_query_common.sql:476: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------+----------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date | public.time_bucket(interval,pg_catalog.date) | @ 4 days | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date | time_bucket(interval,date) | @ 4 days | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date; -psql:include/cagg_query_common.sql:477: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk +psql:include/cagg_query_common.sql:478: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, '2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:483: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" +psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin; -psql:include/cagg_query_common.sql:485: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk +psql:include/cagg_query_common.sql:486: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, origin=>'2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:491: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" +psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin2 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin2; -psql:include/cagg_query_common.sql:493: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk +psql:include/cagg_query_common.sql:494: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, "offset"=>'30m'::interval), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:499: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" +psql:include/cagg_query_common.sql:500: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_offset | public.time_bucket(interval,pg_catalog.date,interval) | @ 4 days | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_offset | time_bucket(interval,date,interval) | @ 4 days | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_offset; -psql:include/cagg_query_common.sql:501: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk +psql:include/cagg_query_common.sql:502: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk -- Integer based CAggs CREATE MATERIALIZED VIEW cagg_smallint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:508: NOTICE: refreshing continuous aggregate "cagg_smallint" +psql:include/cagg_query_common.sql:509: NOTICE: refreshing continuous aggregate "cagg_smallint" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+---------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint | public.time_bucket(smallint,smallint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+--------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint | time_bucket(smallint,smallint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint; -psql:include/cagg_query_common.sql:510: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk +psql:include/cagg_query_common.sql:511: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk CREATE MATERIALIZED VIEW cagg_smallint_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::smallint), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:516: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" +psql:include/cagg_query_common.sql:517: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint_offset | public.time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-----------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint_offset | time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint_offset; -psql:include/cagg_query_common.sql:518: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk +psql:include/cagg_query_common.sql:519: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk CREATE MATERIALIZED VIEW cagg_int WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:524: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:525: NOTICE: refreshing continuous aggregate "cagg_int" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int | public.time_bucket(integer,integer) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int | time_bucket(integer,integer) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_int; -psql:include/cagg_query_common.sql:526: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk +psql:include/cagg_query_common.sql:527: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::int), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:532: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:533: NOTICE: refreshing continuous aggregate "cagg_int_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-----------------+---------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int_offset | public.time_bucket(integer,integer,integer) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-----------------+--------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int_offset | time_bucket(integer,integer,integer) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_int_offset; -psql:include/cagg_query_common.sql:534: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk +psql:include/cagg_query_common.sql:535: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk CREATE MATERIALIZED VIEW cagg_bigint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint | public.time_bucket(bigint,bigint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint | time_bucket(bigint,bigint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint; @@ -1149,9 +1150,9 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint_offset; @@ -1162,22 +1163,11 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset2 FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset2 | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset2 | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) --- mess with the bucket_func signature to make sure it will raise an exception -SET ROLE :ROLE_CLUSTER_SUPERUSER; -\set ON_ERROR_STOP 0 -BEGIN; -UPDATE _timescaledb_catalog.continuous_aggs_bucket_function SET bucket_func = 'func_does_not_exist()'; --- should error because function does not exist -CALL refresh_continuous_aggregate('cagg_bigint_offset2', NULL, NULL); -psql:include/cagg_query_common.sql:566: ERROR: function "func_does_not_exist()" does not exist -ROLLBACK; -\set ON_ERROR_STOP 1 -SET ROLE :ROLE_DEFAULT_PERM_USER; DROP MATERIALIZED VIEW cagg_bigint_offset2; -- Test invalid bucket definitions \set ON_ERROR_STOP 0 @@ -1187,14 +1177,14 @@ CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:580: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 +psql:include/cagg_query_common.sql:570: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 -- Offset and origin at the same time is not allowed (function does exists but invalid parameter combination) CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:587: ERROR: using offset and origin in a time_bucket function at the same time is not supported +psql:include/cagg_query_common.sql:577: ERROR: using offset and origin in a time_bucket function at the same time is not supported \set ON_ERROR_STOP 1 --- -- Tests with CAgg processing @@ -1221,20 +1211,20 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:613: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:603: NOTICE: refreshing continuous aggregate "cagg_4_hours" CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:619: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:609: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" -- Align origin with first value CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:626: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:616: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" -- Query the CAggs and check that all buckets are materialized SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; time_bucket | max @@ -1543,24 +1533,24 @@ SELECT * FROM cagg_4_hours_origin; -- Update materialized data SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] -psql:include/cagg_query_common.sql:683: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:683: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:673: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:673: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] +psql:include/cagg_query_common.sql:673: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:673: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:684: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] -psql:include/cagg_query_common.sql:684: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:684: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:674: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:674: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] +psql:include/cagg_query_common.sql:674: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:685: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] -psql:include/cagg_query_common.sql:685: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:685: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:675: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:675: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] +psql:include/cagg_query_common.sql:675: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" RESET client_min_messages; -psql:include/cagg_query_common.sql:686: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:676: LOG: statement: RESET client_min_messages; -- Query the CAggs and check that all buckets are materialized SELECT * FROM cagg_4_hours; time_bucket | max @@ -1763,40 +1753,40 @@ INSERT INTO temperature values('2020-01-02 01:35:00+01', 5555); INSERT INTO temperature values('2020-01-02 05:05:00+01', 8888); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] -psql:include/cagg_query_common.sql:725: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] -psql:include/cagg_query_common.sql:725: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] +psql:include/cagg_query_common.sql:715: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] +psql:include/cagg_query_common.sql:715: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] -psql:include/cagg_query_common.sql:726: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] -psql:include/cagg_query_common.sql:726: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 +psql:include/cagg_query_common.sql:716: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] +psql:include/cagg_query_common.sql:716: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] +psql:include/cagg_query_common.sql:716: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] -psql:include/cagg_query_common.sql:727: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] -psql:include/cagg_query_common.sql:727: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 +psql:include/cagg_query_common.sql:717: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] +psql:include/cagg_query_common.sql:717: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] +psql:include/cagg_query_common.sql:717: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 RESET client_min_messages; -psql:include/cagg_query_common.sql:728: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:718: LOG: statement: RESET client_min_messages; ALTER MATERIALIZED VIEW cagg_4_hours SET (timescaledb.materialized_only=true); SELECT * FROM cagg_4_hours; time_bucket | max @@ -1992,7 +1982,7 @@ CREATE MATERIALIZED VIEW cagg_1_year SELECT time_bucket('1 year', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:766: NOTICE: refreshing continuous aggregate "cagg_1_year" +psql:include/cagg_query_common.sql:756: NOTICE: refreshing continuous aggregate "cagg_1_year" SELECT * FROM _timescaledb_catalog.continuous_aggs_materialization_invalidation_log ORDER BY 1, 2, 3; materialization_id | lowest_modified_value | greatest_modified_value --------------------+-----------------------+------------------------- @@ -2024,13 +2014,13 @@ CREATE MATERIALIZED VIEW cagg_int AS SELECT time_bucket('10', time), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:783: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:773: NOTICE: refreshing continuous aggregate "cagg_int" CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>5), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:789: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:779: NOTICE: refreshing continuous aggregate "cagg_int_offset" -- Compare bucketing results SELECT time_bucket('10', time), SUM(data) FROM table_int GROUP BY 1 ORDER BY 1; time_bucket | sum @@ -2245,14 +2235,14 @@ SELECT * FROM cagg_int_offset; INSERT INTO table_int VALUES(114, 0); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] -psql:include/cagg_query_common.sql:824: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_38" -psql:include/cagg_query_common.sql:824: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially -psql:include/cagg_query_common.sql:824: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication -psql:include/cagg_query_common.sql:824: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" +psql:include/cagg_query_common.sql:814: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); +psql:include/cagg_query_common.sql:814: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] +psql:include/cagg_query_common.sql:814: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_38" +psql:include/cagg_query_common.sql:814: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially +psql:include/cagg_query_common.sql:814: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication +psql:include/cagg_query_common.sql:814: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" RESET client_min_messages; -psql:include/cagg_query_common.sql:825: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:815: LOG: statement: RESET client_min_messages; SELECT * FROM cagg_int_offset; time_bucket | value -------------+------- @@ -2295,45 +2285,45 @@ CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin SELECT time_bucket('1 year', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:835: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" +psql:include/cagg_query_common.sql:825: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin; -psql:include/cagg_query_common.sql:837: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:827: NOTICE: drop cascades to 2 other objects -- Variable due to the used timezone CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2 WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:844: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" +psql:include/cagg_query_common.sql:834: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2; -psql:include/cagg_query_common.sql:846: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:836: NOTICE: drop cascades to 2 other objects -- Variable with offset CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3 WITH (timescaledb.continuous) AS SELECT time_bucket('1 year', time, "offset"=>'5 minutes'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:853: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" +psql:include/cagg_query_common.sql:843: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin3'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin3 | public.time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin3 | time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3; -psql:include/cagg_query_common.sql:855: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:845: NOTICE: drop cascades to 2 other objects --- -- Test with blocking a few broken configurations --- @@ -2346,26 +2336,26 @@ CREATE MATERIALIZED VIEW cagg_1_hour_origin SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:870: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" +psql:include/cagg_query_common.sql:860: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" CREATE MATERIALIZED VIEW cagg_1_week_origin WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, origin=>'2022-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_origin GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:876: ERROR: cannot create continuous aggregate with different bucket origin values +psql:include/cagg_query_common.sql:866: ERROR: cannot create continuous aggregate with different bucket origin values -- Different time offset CREATE MATERIALIZED VIEW cagg_1_hour_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, "offset"=>'30m'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:883: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:873: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" CREATE MATERIALIZED VIEW cagg_1_week_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:889: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:879: ERROR: cannot create continuous aggregate with different bucket offset values -- Cagg with NULL offset on top of cagg with non-NULL offset \set VERBOSITY default CREATE MATERIALIZED VIEW cagg_1_week_null_offset @@ -2373,7 +2363,7 @@ CREATE MATERIALIZED VIEW cagg_1_week_null_offset SELECT time_bucket('1 week', hour_bucket, "offset"=>NULL::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:897: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:887: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_null_offset" [NULL] and "public.cagg_1_hour_offset" [@ 30 mins] should be the same. -- Cagg with non-NULL offset on top of cagg with NULL offset CREATE MATERIALIZED VIEW cagg_1_hour_null_offset @@ -2381,14 +2371,14 @@ CREATE MATERIALIZED VIEW cagg_1_hour_null_offset SELECT time_bucket('1 hour', time, "offset"=>NULL::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:904: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" +psql:include/cagg_query_common.sql:894: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" HINT: Use WITH NO DATA if you do not want to refresh the continuous aggregate on creation. CREATE MATERIALIZED VIEW cagg_1_week_non_null_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_null_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:910: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:900: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_non_null_offset" [@ 35 mins] and "public.cagg_1_hour_null_offset" [NULL] should be the same. \set VERBOSITY terse -- Different integer offset @@ -2397,20 +2387,20 @@ CREATE MATERIALIZED VIEW cagg_int_offset_5 AS SELECT time_bucket('10', time, "offset"=>5) AS time, SUM(data) AS value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:918: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" +psql:include/cagg_query_common.sql:908: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" CREATE MATERIALIZED VIEW cagg_int_offset_10 WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>10) AS time, SUM(value) AS value FROM cagg_int_offset_5 GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:924: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:914: ERROR: cannot create continuous aggregate with different bucket offset values \set ON_ERROR_STOP 1 DROP MATERIALIZED VIEW cagg_1_hour_origin; -psql:include/cagg_query_common.sql:928: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:918: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_1_hour_offset; -psql:include/cagg_query_common.sql:929: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:919: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_int_offset_5; -psql:include/cagg_query_common.sql:930: NOTICE: drop cascades to 3 other objects +psql:include/cagg_query_common.sql:920: NOTICE: drop cascades to 3 other objects --- -- CAGGs on CAGGs tests --- @@ -2419,11 +2409,11 @@ CREATE MATERIALIZED VIEW cagg_1_hour_offset SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:939: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:929: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) CREATE MATERIALIZED VIEW cagg_1_week_offset @@ -2431,11 +2421,11 @@ CREATE MATERIALIZED VIEW cagg_1_week_offset SELECT time_bucket('1 week', hour_bucket, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:946: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" +psql:include/cagg_query_common.sql:936: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_week_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_week_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_week_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) -- Compare output diff --git a/tsl/test/expected/cagg_query-15.out b/tsl/test/expected/cagg_query-15.out index 4739c69f52f..6d9eff93180 100644 --- a/tsl/test/expected/cagg_query-15.out +++ b/tsl/test/expected/cagg_query-15.out @@ -11,6 +11,7 @@ SET ROLE :ROLE_DEFAULT_PERM_USER; -- This file and its contents are licensed under the Timescale License. -- Please see the included NOTICE for copyright information and -- LICENSE-TIMESCALE for a copy of the license. +\set TEST_BASE_NAME cagg_query SELECT format('%s/results/%s_results_view.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW", format('%s/results/%s_results_view_hashagg.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW_HASHAGG", @@ -761,7 +762,7 @@ CREATE TABLE temperature_wo_tz ( value float ); SELECT create_hypertable('temperature_wo_tz', 'time'); -psql:include/cagg_query_common.sql:316: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices +psql:include/cagg_query_common.sql:317: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices create_hypertable -------------------------------- (5,public,temperature_wo_tz,t) @@ -793,21 +794,21 @@ CREATE TABLE table_bigint ( data bigint ); SELECT create_hypertable('table_smallint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:345: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" create_hypertable ----------------------------- (7,public,table_smallint,t) (1 row) SELECT create_hypertable('table_int', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" create_hypertable ------------------------ (8,public,table_int,t) (1 row) SELECT create_hypertable('table_bigint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:348: NOTICE: adding not-null constraint to column "time" create_hypertable --------------------------- (9,public,table_bigint,t) @@ -839,7 +840,7 @@ INSERT INTO table_int VALUES(1,2); INSERT INTO table_bigint VALUES(1,2); CREATE VIEW caggs_info AS SELECT user_view_schema, user_view_name, bucket_func, bucket_width, bucket_origin, bucket_offset, bucket_timezone, bucket_fixed_width -FROM _timescaledb_catalog.continuous_aggs_bucket_function NATURAL JOIN _timescaledb_catalog.continuous_agg; +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id); --- -- Tests with CAgg creation --- @@ -848,128 +849,128 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:372: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:373: NOTICE: refreshing continuous aggregate "cagg_4_hours" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours | public.time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours | time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours; -psql:include/cagg_query_common.sql:374: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk +psql:include/cagg_query_common.sql:375: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:380: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:381: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset; -psql:include/cagg_query_common.sql:382: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk +psql:include/cagg_query_common.sql:383: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:388: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" +psql:include/cagg_query_common.sql:389: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset2 | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset2 | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset2; -psql:include/cagg_query_common.sql:390: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk +psql:include/cagg_query_common.sql:391: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk -- Variable buckets (timezone is provided) with offset CREATE MATERIALIZED VIEW cagg_4_hours_offset_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:397: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" +psql:include/cagg_query_common.sql:398: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_ts; -psql:include/cagg_query_common.sql:399: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk +psql:include/cagg_query_common.sql:400: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:405: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:406: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin; -psql:include/cagg_query_common.sql:407: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk +psql:include/cagg_query_common.sql:408: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk -- Using named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:414: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" +psql:include/cagg_query_common.sql:415: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin2 | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin2 | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin2; -psql:include/cagg_query_common.sql:416: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk +psql:include/cagg_query_common.sql:417: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:423: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" +psql:include/cagg_query_common.sql:424: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts; -psql:include/cagg_query_common.sql:425: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk +psql:include/cagg_query_common.sql:426: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk -- Without named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, 'UTC', '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:432: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" +psql:include/cagg_query_common.sql:433: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts2; -psql:include/cagg_query_common.sql:434: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk +psql:include/cagg_query_common.sql:435: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk -- Timestamp based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:441: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" +psql:include/cagg_query_common.sql:442: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+----------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_wo_tz | public.time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+---------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_wo_tz | time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t (1 row) CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz @@ -977,169 +978,169 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:448: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" +psql:include/cagg_query_common.sql:449: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz; -psql:include/cagg_query_common.sql:450: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk +psql:include/cagg_query_common.sql:451: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:457: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" +psql:include/cagg_query_common.sql:458: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz2 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz2 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2; -psql:include/cagg_query_common.sql:459: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk +psql:include/cagg_query_common.sql:460: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:465: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" +psql:include/cagg_query_common.sql:466: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+-------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_wo_tz | public.time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_wo_tz | time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_wo_tz; -psql:include/cagg_query_common.sql:467: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk +psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk DROP MATERIALIZED VIEW cagg_4_hours_wo_tz; -psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk +psql:include/cagg_query_common.sql:469: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk -- Date based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_date WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:475: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" +psql:include/cagg_query_common.sql:476: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------+----------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date | public.time_bucket(interval,pg_catalog.date) | @ 4 days | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date | time_bucket(interval,date) | @ 4 days | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date; -psql:include/cagg_query_common.sql:477: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk +psql:include/cagg_query_common.sql:478: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, '2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:483: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" +psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin; -psql:include/cagg_query_common.sql:485: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk +psql:include/cagg_query_common.sql:486: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, origin=>'2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:491: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" +psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin2 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin2; -psql:include/cagg_query_common.sql:493: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk +psql:include/cagg_query_common.sql:494: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, "offset"=>'30m'::interval), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:499: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" +psql:include/cagg_query_common.sql:500: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_offset | public.time_bucket(interval,pg_catalog.date,interval) | @ 4 days | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_offset | time_bucket(interval,date,interval) | @ 4 days | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_offset; -psql:include/cagg_query_common.sql:501: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk +psql:include/cagg_query_common.sql:502: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk -- Integer based CAggs CREATE MATERIALIZED VIEW cagg_smallint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:508: NOTICE: refreshing continuous aggregate "cagg_smallint" +psql:include/cagg_query_common.sql:509: NOTICE: refreshing continuous aggregate "cagg_smallint" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+---------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint | public.time_bucket(smallint,smallint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+--------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint | time_bucket(smallint,smallint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint; -psql:include/cagg_query_common.sql:510: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk +psql:include/cagg_query_common.sql:511: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk CREATE MATERIALIZED VIEW cagg_smallint_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::smallint), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:516: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" +psql:include/cagg_query_common.sql:517: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint_offset | public.time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-----------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint_offset | time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint_offset; -psql:include/cagg_query_common.sql:518: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk +psql:include/cagg_query_common.sql:519: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk CREATE MATERIALIZED VIEW cagg_int WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:524: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:525: NOTICE: refreshing continuous aggregate "cagg_int" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int | public.time_bucket(integer,integer) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int | time_bucket(integer,integer) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_int; -psql:include/cagg_query_common.sql:526: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk +psql:include/cagg_query_common.sql:527: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::int), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:532: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:533: NOTICE: refreshing continuous aggregate "cagg_int_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-----------------+---------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int_offset | public.time_bucket(integer,integer,integer) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-----------------+--------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int_offset | time_bucket(integer,integer,integer) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_int_offset; -psql:include/cagg_query_common.sql:534: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk +psql:include/cagg_query_common.sql:535: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk CREATE MATERIALIZED VIEW cagg_bigint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint | public.time_bucket(bigint,bigint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint | time_bucket(bigint,bigint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint; @@ -1149,9 +1150,9 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint_offset; @@ -1162,22 +1163,11 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset2 FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset2 | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset2 | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) --- mess with the bucket_func signature to make sure it will raise an exception -SET ROLE :ROLE_CLUSTER_SUPERUSER; -\set ON_ERROR_STOP 0 -BEGIN; -UPDATE _timescaledb_catalog.continuous_aggs_bucket_function SET bucket_func = 'func_does_not_exist()'; --- should error because function does not exist -CALL refresh_continuous_aggregate('cagg_bigint_offset2', NULL, NULL); -psql:include/cagg_query_common.sql:566: ERROR: function "func_does_not_exist()" does not exist -ROLLBACK; -\set ON_ERROR_STOP 1 -SET ROLE :ROLE_DEFAULT_PERM_USER; DROP MATERIALIZED VIEW cagg_bigint_offset2; -- Test invalid bucket definitions \set ON_ERROR_STOP 0 @@ -1187,14 +1177,14 @@ CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:580: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 +psql:include/cagg_query_common.sql:570: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 -- Offset and origin at the same time is not allowed (function does exists but invalid parameter combination) CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:587: ERROR: using offset and origin in a time_bucket function at the same time is not supported +psql:include/cagg_query_common.sql:577: ERROR: using offset and origin in a time_bucket function at the same time is not supported \set ON_ERROR_STOP 1 --- -- Tests with CAgg processing @@ -1221,20 +1211,20 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:613: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:603: NOTICE: refreshing continuous aggregate "cagg_4_hours" CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:619: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:609: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" -- Align origin with first value CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:626: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:616: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" -- Query the CAggs and check that all buckets are materialized SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; time_bucket | max @@ -1543,24 +1533,24 @@ SELECT * FROM cagg_4_hours_origin; -- Update materialized data SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] -psql:include/cagg_query_common.sql:683: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:683: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:673: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:673: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] +psql:include/cagg_query_common.sql:673: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:673: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:684: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] -psql:include/cagg_query_common.sql:684: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:684: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:674: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:674: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] +psql:include/cagg_query_common.sql:674: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:685: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] -psql:include/cagg_query_common.sql:685: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:685: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:675: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:675: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] +psql:include/cagg_query_common.sql:675: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" RESET client_min_messages; -psql:include/cagg_query_common.sql:686: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:676: LOG: statement: RESET client_min_messages; -- Query the CAggs and check that all buckets are materialized SELECT * FROM cagg_4_hours; time_bucket | max @@ -1763,40 +1753,40 @@ INSERT INTO temperature values('2020-01-02 01:35:00+01', 5555); INSERT INTO temperature values('2020-01-02 05:05:00+01', 8888); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] -psql:include/cagg_query_common.sql:725: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] -psql:include/cagg_query_common.sql:725: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] +psql:include/cagg_query_common.sql:715: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] +psql:include/cagg_query_common.sql:715: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] -psql:include/cagg_query_common.sql:726: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] -psql:include/cagg_query_common.sql:726: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 +psql:include/cagg_query_common.sql:716: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] +psql:include/cagg_query_common.sql:716: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] +psql:include/cagg_query_common.sql:716: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] -psql:include/cagg_query_common.sql:727: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] -psql:include/cagg_query_common.sql:727: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 +psql:include/cagg_query_common.sql:717: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] +psql:include/cagg_query_common.sql:717: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] +psql:include/cagg_query_common.sql:717: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 RESET client_min_messages; -psql:include/cagg_query_common.sql:728: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:718: LOG: statement: RESET client_min_messages; ALTER MATERIALIZED VIEW cagg_4_hours SET (timescaledb.materialized_only=true); SELECT * FROM cagg_4_hours; time_bucket | max @@ -1992,7 +1982,7 @@ CREATE MATERIALIZED VIEW cagg_1_year SELECT time_bucket('1 year', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:766: NOTICE: refreshing continuous aggregate "cagg_1_year" +psql:include/cagg_query_common.sql:756: NOTICE: refreshing continuous aggregate "cagg_1_year" SELECT * FROM _timescaledb_catalog.continuous_aggs_materialization_invalidation_log ORDER BY 1, 2, 3; materialization_id | lowest_modified_value | greatest_modified_value --------------------+-----------------------+------------------------- @@ -2024,13 +2014,13 @@ CREATE MATERIALIZED VIEW cagg_int AS SELECT time_bucket('10', time), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:783: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:773: NOTICE: refreshing continuous aggregate "cagg_int" CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>5), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:789: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:779: NOTICE: refreshing continuous aggregate "cagg_int_offset" -- Compare bucketing results SELECT time_bucket('10', time), SUM(data) FROM table_int GROUP BY 1 ORDER BY 1; time_bucket | sum @@ -2245,14 +2235,14 @@ SELECT * FROM cagg_int_offset; INSERT INTO table_int VALUES(114, 0); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] -psql:include/cagg_query_common.sql:824: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_38" -psql:include/cagg_query_common.sql:824: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially -psql:include/cagg_query_common.sql:824: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication -psql:include/cagg_query_common.sql:824: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" +psql:include/cagg_query_common.sql:814: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); +psql:include/cagg_query_common.sql:814: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] +psql:include/cagg_query_common.sql:814: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_38" +psql:include/cagg_query_common.sql:814: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially +psql:include/cagg_query_common.sql:814: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication +psql:include/cagg_query_common.sql:814: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" RESET client_min_messages; -psql:include/cagg_query_common.sql:825: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:815: LOG: statement: RESET client_min_messages; SELECT * FROM cagg_int_offset; time_bucket | value -------------+------- @@ -2295,45 +2285,45 @@ CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin SELECT time_bucket('1 year', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:835: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" +psql:include/cagg_query_common.sql:825: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin; -psql:include/cagg_query_common.sql:837: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:827: NOTICE: drop cascades to 2 other objects -- Variable due to the used timezone CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2 WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:844: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" +psql:include/cagg_query_common.sql:834: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2; -psql:include/cagg_query_common.sql:846: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:836: NOTICE: drop cascades to 2 other objects -- Variable with offset CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3 WITH (timescaledb.continuous) AS SELECT time_bucket('1 year', time, "offset"=>'5 minutes'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:853: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" +psql:include/cagg_query_common.sql:843: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin3'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin3 | public.time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin3 | time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3; -psql:include/cagg_query_common.sql:855: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:845: NOTICE: drop cascades to 2 other objects --- -- Test with blocking a few broken configurations --- @@ -2346,26 +2336,26 @@ CREATE MATERIALIZED VIEW cagg_1_hour_origin SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:870: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" +psql:include/cagg_query_common.sql:860: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" CREATE MATERIALIZED VIEW cagg_1_week_origin WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, origin=>'2022-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_origin GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:876: ERROR: cannot create continuous aggregate with different bucket origin values +psql:include/cagg_query_common.sql:866: ERROR: cannot create continuous aggregate with different bucket origin values -- Different time offset CREATE MATERIALIZED VIEW cagg_1_hour_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, "offset"=>'30m'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:883: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:873: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" CREATE MATERIALIZED VIEW cagg_1_week_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:889: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:879: ERROR: cannot create continuous aggregate with different bucket offset values -- Cagg with NULL offset on top of cagg with non-NULL offset \set VERBOSITY default CREATE MATERIALIZED VIEW cagg_1_week_null_offset @@ -2373,7 +2363,7 @@ CREATE MATERIALIZED VIEW cagg_1_week_null_offset SELECT time_bucket('1 week', hour_bucket, "offset"=>NULL::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:897: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:887: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_null_offset" [NULL] and "public.cagg_1_hour_offset" [@ 30 mins] should be the same. -- Cagg with non-NULL offset on top of cagg with NULL offset CREATE MATERIALIZED VIEW cagg_1_hour_null_offset @@ -2381,14 +2371,14 @@ CREATE MATERIALIZED VIEW cagg_1_hour_null_offset SELECT time_bucket('1 hour', time, "offset"=>NULL::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:904: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" +psql:include/cagg_query_common.sql:894: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" HINT: Use WITH NO DATA if you do not want to refresh the continuous aggregate on creation. CREATE MATERIALIZED VIEW cagg_1_week_non_null_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_null_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:910: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:900: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_non_null_offset" [@ 35 mins] and "public.cagg_1_hour_null_offset" [NULL] should be the same. \set VERBOSITY terse -- Different integer offset @@ -2397,20 +2387,20 @@ CREATE MATERIALIZED VIEW cagg_int_offset_5 AS SELECT time_bucket('10', time, "offset"=>5) AS time, SUM(data) AS value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:918: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" +psql:include/cagg_query_common.sql:908: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" CREATE MATERIALIZED VIEW cagg_int_offset_10 WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>10) AS time, SUM(value) AS value FROM cagg_int_offset_5 GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:924: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:914: ERROR: cannot create continuous aggregate with different bucket offset values \set ON_ERROR_STOP 1 DROP MATERIALIZED VIEW cagg_1_hour_origin; -psql:include/cagg_query_common.sql:928: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:918: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_1_hour_offset; -psql:include/cagg_query_common.sql:929: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:919: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_int_offset_5; -psql:include/cagg_query_common.sql:930: NOTICE: drop cascades to 3 other objects +psql:include/cagg_query_common.sql:920: NOTICE: drop cascades to 3 other objects --- -- CAGGs on CAGGs tests --- @@ -2419,11 +2409,11 @@ CREATE MATERIALIZED VIEW cagg_1_hour_offset SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:939: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:929: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) CREATE MATERIALIZED VIEW cagg_1_week_offset @@ -2431,11 +2421,11 @@ CREATE MATERIALIZED VIEW cagg_1_week_offset SELECT time_bucket('1 week', hour_bucket, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:946: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" +psql:include/cagg_query_common.sql:936: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_week_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_week_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_week_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) -- Compare output diff --git a/tsl/test/expected/cagg_query-16.out b/tsl/test/expected/cagg_query-16.out index 84ddfb0b714..cc1aa89958a 100644 --- a/tsl/test/expected/cagg_query-16.out +++ b/tsl/test/expected/cagg_query-16.out @@ -11,6 +11,7 @@ SET ROLE :ROLE_DEFAULT_PERM_USER; -- This file and its contents are licensed under the Timescale License. -- Please see the included NOTICE for copyright information and -- LICENSE-TIMESCALE for a copy of the license. +\set TEST_BASE_NAME cagg_query SELECT format('%s/results/%s_results_view.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW", format('%s/results/%s_results_view_hashagg.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW_HASHAGG", @@ -755,7 +756,7 @@ CREATE TABLE temperature_wo_tz ( value float ); SELECT create_hypertable('temperature_wo_tz', 'time'); -psql:include/cagg_query_common.sql:316: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices +psql:include/cagg_query_common.sql:317: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices create_hypertable -------------------------------- (5,public,temperature_wo_tz,t) @@ -787,21 +788,21 @@ CREATE TABLE table_bigint ( data bigint ); SELECT create_hypertable('table_smallint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:345: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" create_hypertable ----------------------------- (7,public,table_smallint,t) (1 row) SELECT create_hypertable('table_int', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" create_hypertable ------------------------ (8,public,table_int,t) (1 row) SELECT create_hypertable('table_bigint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:348: NOTICE: adding not-null constraint to column "time" create_hypertable --------------------------- (9,public,table_bigint,t) @@ -833,7 +834,7 @@ INSERT INTO table_int VALUES(1,2); INSERT INTO table_bigint VALUES(1,2); CREATE VIEW caggs_info AS SELECT user_view_schema, user_view_name, bucket_func, bucket_width, bucket_origin, bucket_offset, bucket_timezone, bucket_fixed_width -FROM _timescaledb_catalog.continuous_aggs_bucket_function NATURAL JOIN _timescaledb_catalog.continuous_agg; +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id); --- -- Tests with CAgg creation --- @@ -842,128 +843,128 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:372: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:373: NOTICE: refreshing continuous aggregate "cagg_4_hours" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours | public.time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours | time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours; -psql:include/cagg_query_common.sql:374: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk +psql:include/cagg_query_common.sql:375: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:380: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:381: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset; -psql:include/cagg_query_common.sql:382: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk +psql:include/cagg_query_common.sql:383: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:388: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" +psql:include/cagg_query_common.sql:389: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset2 | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset2 | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset2; -psql:include/cagg_query_common.sql:390: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk +psql:include/cagg_query_common.sql:391: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk -- Variable buckets (timezone is provided) with offset CREATE MATERIALIZED VIEW cagg_4_hours_offset_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:397: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" +psql:include/cagg_query_common.sql:398: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_ts; -psql:include/cagg_query_common.sql:399: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk +psql:include/cagg_query_common.sql:400: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:405: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:406: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin; -psql:include/cagg_query_common.sql:407: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk +psql:include/cagg_query_common.sql:408: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk -- Using named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:414: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" +psql:include/cagg_query_common.sql:415: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin2 | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin2 | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin2; -psql:include/cagg_query_common.sql:416: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk +psql:include/cagg_query_common.sql:417: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:423: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" +psql:include/cagg_query_common.sql:424: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts; -psql:include/cagg_query_common.sql:425: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk +psql:include/cagg_query_common.sql:426: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk -- Without named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, 'UTC', '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:432: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" +psql:include/cagg_query_common.sql:433: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts2; -psql:include/cagg_query_common.sql:434: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk +psql:include/cagg_query_common.sql:435: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk -- Timestamp based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:441: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" +psql:include/cagg_query_common.sql:442: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+----------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_wo_tz | public.time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+---------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_wo_tz | time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t (1 row) CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz @@ -971,169 +972,169 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:448: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" +psql:include/cagg_query_common.sql:449: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz; -psql:include/cagg_query_common.sql:450: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk +psql:include/cagg_query_common.sql:451: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:457: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" +psql:include/cagg_query_common.sql:458: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz2 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz2 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2; -psql:include/cagg_query_common.sql:459: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk +psql:include/cagg_query_common.sql:460: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:465: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" +psql:include/cagg_query_common.sql:466: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+-------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_wo_tz | public.time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_wo_tz | time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_wo_tz; -psql:include/cagg_query_common.sql:467: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk +psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk DROP MATERIALIZED VIEW cagg_4_hours_wo_tz; -psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk +psql:include/cagg_query_common.sql:469: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk -- Date based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_date WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:475: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" +psql:include/cagg_query_common.sql:476: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------+----------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date | public.time_bucket(interval,pg_catalog.date) | @ 4 days | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date | time_bucket(interval,date) | @ 4 days | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date; -psql:include/cagg_query_common.sql:477: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk +psql:include/cagg_query_common.sql:478: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, '2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:483: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" +psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin; -psql:include/cagg_query_common.sql:485: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk +psql:include/cagg_query_common.sql:486: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, origin=>'2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:491: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" +psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin2 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin2; -psql:include/cagg_query_common.sql:493: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk +psql:include/cagg_query_common.sql:494: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, "offset"=>'30m'::interval), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:499: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" +psql:include/cagg_query_common.sql:500: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_offset | public.time_bucket(interval,pg_catalog.date,interval) | @ 4 days | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_offset | time_bucket(interval,date,interval) | @ 4 days | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_offset; -psql:include/cagg_query_common.sql:501: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk +psql:include/cagg_query_common.sql:502: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk -- Integer based CAggs CREATE MATERIALIZED VIEW cagg_smallint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:508: NOTICE: refreshing continuous aggregate "cagg_smallint" +psql:include/cagg_query_common.sql:509: NOTICE: refreshing continuous aggregate "cagg_smallint" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+---------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint | public.time_bucket(smallint,smallint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+--------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint | time_bucket(smallint,smallint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint; -psql:include/cagg_query_common.sql:510: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk +psql:include/cagg_query_common.sql:511: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk CREATE MATERIALIZED VIEW cagg_smallint_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::smallint), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:516: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" +psql:include/cagg_query_common.sql:517: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint_offset | public.time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-----------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint_offset | time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint_offset; -psql:include/cagg_query_common.sql:518: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk +psql:include/cagg_query_common.sql:519: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk CREATE MATERIALIZED VIEW cagg_int WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:524: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:525: NOTICE: refreshing continuous aggregate "cagg_int" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int | public.time_bucket(integer,integer) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int | time_bucket(integer,integer) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_int; -psql:include/cagg_query_common.sql:526: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk +psql:include/cagg_query_common.sql:527: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::int), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:532: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:533: NOTICE: refreshing continuous aggregate "cagg_int_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-----------------+---------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int_offset | public.time_bucket(integer,integer,integer) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-----------------+--------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int_offset | time_bucket(integer,integer,integer) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_int_offset; -psql:include/cagg_query_common.sql:534: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk +psql:include/cagg_query_common.sql:535: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk CREATE MATERIALIZED VIEW cagg_bigint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint | public.time_bucket(bigint,bigint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint | time_bucket(bigint,bigint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint; @@ -1143,9 +1144,9 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint_offset; @@ -1156,22 +1157,11 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset2 FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset2 | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset2 | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) --- mess with the bucket_func signature to make sure it will raise an exception -SET ROLE :ROLE_CLUSTER_SUPERUSER; -\set ON_ERROR_STOP 0 -BEGIN; -UPDATE _timescaledb_catalog.continuous_aggs_bucket_function SET bucket_func = 'func_does_not_exist()'; --- should error because function does not exist -CALL refresh_continuous_aggregate('cagg_bigint_offset2', NULL, NULL); -psql:include/cagg_query_common.sql:566: ERROR: function "func_does_not_exist()" does not exist -ROLLBACK; -\set ON_ERROR_STOP 1 -SET ROLE :ROLE_DEFAULT_PERM_USER; DROP MATERIALIZED VIEW cagg_bigint_offset2; -- Test invalid bucket definitions \set ON_ERROR_STOP 0 @@ -1181,14 +1171,14 @@ CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:580: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 +psql:include/cagg_query_common.sql:570: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 -- Offset and origin at the same time is not allowed (function does exists but invalid parameter combination) CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:587: ERROR: using offset and origin in a time_bucket function at the same time is not supported +psql:include/cagg_query_common.sql:577: ERROR: using offset and origin in a time_bucket function at the same time is not supported \set ON_ERROR_STOP 1 --- -- Tests with CAgg processing @@ -1215,20 +1205,20 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:613: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:603: NOTICE: refreshing continuous aggregate "cagg_4_hours" CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:619: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:609: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" -- Align origin with first value CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:626: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:616: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" -- Query the CAggs and check that all buckets are materialized SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; time_bucket | max @@ -1537,24 +1527,24 @@ SELECT * FROM cagg_4_hours_origin; -- Update materialized data SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] -psql:include/cagg_query_common.sql:683: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:683: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:673: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:673: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] +psql:include/cagg_query_common.sql:673: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:673: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:684: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] -psql:include/cagg_query_common.sql:684: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:684: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:674: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:674: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] +psql:include/cagg_query_common.sql:674: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:685: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] -psql:include/cagg_query_common.sql:685: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:685: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:675: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:675: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] +psql:include/cagg_query_common.sql:675: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" RESET client_min_messages; -psql:include/cagg_query_common.sql:686: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:676: LOG: statement: RESET client_min_messages; -- Query the CAggs and check that all buckets are materialized SELECT * FROM cagg_4_hours; time_bucket | max @@ -1757,40 +1747,40 @@ INSERT INTO temperature values('2020-01-02 01:35:00+01', 5555); INSERT INTO temperature values('2020-01-02 05:05:00+01', 8888); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] -psql:include/cagg_query_common.sql:725: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] -psql:include/cagg_query_common.sql:725: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] +psql:include/cagg_query_common.sql:715: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] +psql:include/cagg_query_common.sql:715: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] -psql:include/cagg_query_common.sql:726: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] -psql:include/cagg_query_common.sql:726: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 +psql:include/cagg_query_common.sql:716: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] +psql:include/cagg_query_common.sql:716: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] +psql:include/cagg_query_common.sql:716: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] -psql:include/cagg_query_common.sql:727: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] -psql:include/cagg_query_common.sql:727: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 +psql:include/cagg_query_common.sql:717: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] +psql:include/cagg_query_common.sql:717: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] +psql:include/cagg_query_common.sql:717: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 RESET client_min_messages; -psql:include/cagg_query_common.sql:728: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:718: LOG: statement: RESET client_min_messages; ALTER MATERIALIZED VIEW cagg_4_hours SET (timescaledb.materialized_only=true); SELECT * FROM cagg_4_hours; time_bucket | max @@ -1986,7 +1976,7 @@ CREATE MATERIALIZED VIEW cagg_1_year SELECT time_bucket('1 year', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:766: NOTICE: refreshing continuous aggregate "cagg_1_year" +psql:include/cagg_query_common.sql:756: NOTICE: refreshing continuous aggregate "cagg_1_year" SELECT * FROM _timescaledb_catalog.continuous_aggs_materialization_invalidation_log ORDER BY 1, 2, 3; materialization_id | lowest_modified_value | greatest_modified_value --------------------+-----------------------+------------------------- @@ -2018,13 +2008,13 @@ CREATE MATERIALIZED VIEW cagg_int AS SELECT time_bucket('10', time), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:783: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:773: NOTICE: refreshing continuous aggregate "cagg_int" CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>5), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:789: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:779: NOTICE: refreshing continuous aggregate "cagg_int_offset" -- Compare bucketing results SELECT time_bucket('10', time), SUM(data) FROM table_int GROUP BY 1 ORDER BY 1; time_bucket | sum @@ -2239,14 +2229,14 @@ SELECT * FROM cagg_int_offset; INSERT INTO table_int VALUES(114, 0); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] -psql:include/cagg_query_common.sql:824: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_38" -psql:include/cagg_query_common.sql:824: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially -psql:include/cagg_query_common.sql:824: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication -psql:include/cagg_query_common.sql:824: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" +psql:include/cagg_query_common.sql:814: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); +psql:include/cagg_query_common.sql:814: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] +psql:include/cagg_query_common.sql:814: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_38" +psql:include/cagg_query_common.sql:814: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially +psql:include/cagg_query_common.sql:814: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication +psql:include/cagg_query_common.sql:814: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" RESET client_min_messages; -psql:include/cagg_query_common.sql:825: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:815: LOG: statement: RESET client_min_messages; SELECT * FROM cagg_int_offset; time_bucket | value -------------+------- @@ -2289,45 +2279,45 @@ CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin SELECT time_bucket('1 year', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:835: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" +psql:include/cagg_query_common.sql:825: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin; -psql:include/cagg_query_common.sql:837: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:827: NOTICE: drop cascades to 2 other objects -- Variable due to the used timezone CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2 WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:844: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" +psql:include/cagg_query_common.sql:834: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2; -psql:include/cagg_query_common.sql:846: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:836: NOTICE: drop cascades to 2 other objects -- Variable with offset CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3 WITH (timescaledb.continuous) AS SELECT time_bucket('1 year', time, "offset"=>'5 minutes'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:853: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" +psql:include/cagg_query_common.sql:843: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin3'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin3 | public.time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin3 | time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3; -psql:include/cagg_query_common.sql:855: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:845: NOTICE: drop cascades to 2 other objects --- -- Test with blocking a few broken configurations --- @@ -2340,26 +2330,26 @@ CREATE MATERIALIZED VIEW cagg_1_hour_origin SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:870: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" +psql:include/cagg_query_common.sql:860: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" CREATE MATERIALIZED VIEW cagg_1_week_origin WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, origin=>'2022-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_origin GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:876: ERROR: cannot create continuous aggregate with different bucket origin values +psql:include/cagg_query_common.sql:866: ERROR: cannot create continuous aggregate with different bucket origin values -- Different time offset CREATE MATERIALIZED VIEW cagg_1_hour_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, "offset"=>'30m'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:883: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:873: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" CREATE MATERIALIZED VIEW cagg_1_week_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:889: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:879: ERROR: cannot create continuous aggregate with different bucket offset values -- Cagg with NULL offset on top of cagg with non-NULL offset \set VERBOSITY default CREATE MATERIALIZED VIEW cagg_1_week_null_offset @@ -2367,7 +2357,7 @@ CREATE MATERIALIZED VIEW cagg_1_week_null_offset SELECT time_bucket('1 week', hour_bucket, "offset"=>NULL::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:897: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:887: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_null_offset" [NULL] and "public.cagg_1_hour_offset" [@ 30 mins] should be the same. -- Cagg with non-NULL offset on top of cagg with NULL offset CREATE MATERIALIZED VIEW cagg_1_hour_null_offset @@ -2375,14 +2365,14 @@ CREATE MATERIALIZED VIEW cagg_1_hour_null_offset SELECT time_bucket('1 hour', time, "offset"=>NULL::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:904: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" +psql:include/cagg_query_common.sql:894: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" HINT: Use WITH NO DATA if you do not want to refresh the continuous aggregate on creation. CREATE MATERIALIZED VIEW cagg_1_week_non_null_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_null_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:910: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:900: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_non_null_offset" [@ 35 mins] and "public.cagg_1_hour_null_offset" [NULL] should be the same. \set VERBOSITY terse -- Different integer offset @@ -2391,20 +2381,20 @@ CREATE MATERIALIZED VIEW cagg_int_offset_5 AS SELECT time_bucket('10', time, "offset"=>5) AS time, SUM(data) AS value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:918: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" +psql:include/cagg_query_common.sql:908: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" CREATE MATERIALIZED VIEW cagg_int_offset_10 WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>10) AS time, SUM(value) AS value FROM cagg_int_offset_5 GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:924: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:914: ERROR: cannot create continuous aggregate with different bucket offset values \set ON_ERROR_STOP 1 DROP MATERIALIZED VIEW cagg_1_hour_origin; -psql:include/cagg_query_common.sql:928: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:918: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_1_hour_offset; -psql:include/cagg_query_common.sql:929: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:919: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_int_offset_5; -psql:include/cagg_query_common.sql:930: NOTICE: drop cascades to 3 other objects +psql:include/cagg_query_common.sql:920: NOTICE: drop cascades to 3 other objects --- -- CAGGs on CAGGs tests --- @@ -2413,11 +2403,11 @@ CREATE MATERIALIZED VIEW cagg_1_hour_offset SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:939: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:929: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) CREATE MATERIALIZED VIEW cagg_1_week_offset @@ -2425,11 +2415,11 @@ CREATE MATERIALIZED VIEW cagg_1_week_offset SELECT time_bucket('1 week', hour_bucket, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:946: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" +psql:include/cagg_query_common.sql:936: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_week_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_week_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_week_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) -- Compare output diff --git a/tsl/test/expected/cagg_query-17.out b/tsl/test/expected/cagg_query-17.out index 84ddfb0b714..cc1aa89958a 100644 --- a/tsl/test/expected/cagg_query-17.out +++ b/tsl/test/expected/cagg_query-17.out @@ -11,6 +11,7 @@ SET ROLE :ROLE_DEFAULT_PERM_USER; -- This file and its contents are licensed under the Timescale License. -- Please see the included NOTICE for copyright information and -- LICENSE-TIMESCALE for a copy of the license. +\set TEST_BASE_NAME cagg_query SELECT format('%s/results/%s_results_view.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW", format('%s/results/%s_results_view_hashagg.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW_HASHAGG", @@ -755,7 +756,7 @@ CREATE TABLE temperature_wo_tz ( value float ); SELECT create_hypertable('temperature_wo_tz', 'time'); -psql:include/cagg_query_common.sql:316: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices +psql:include/cagg_query_common.sql:317: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices create_hypertable -------------------------------- (5,public,temperature_wo_tz,t) @@ -787,21 +788,21 @@ CREATE TABLE table_bigint ( data bigint ); SELECT create_hypertable('table_smallint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:345: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" create_hypertable ----------------------------- (7,public,table_smallint,t) (1 row) SELECT create_hypertable('table_int', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" create_hypertable ------------------------ (8,public,table_int,t) (1 row) SELECT create_hypertable('table_bigint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:348: NOTICE: adding not-null constraint to column "time" create_hypertable --------------------------- (9,public,table_bigint,t) @@ -833,7 +834,7 @@ INSERT INTO table_int VALUES(1,2); INSERT INTO table_bigint VALUES(1,2); CREATE VIEW caggs_info AS SELECT user_view_schema, user_view_name, bucket_func, bucket_width, bucket_origin, bucket_offset, bucket_timezone, bucket_fixed_width -FROM _timescaledb_catalog.continuous_aggs_bucket_function NATURAL JOIN _timescaledb_catalog.continuous_agg; +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id); --- -- Tests with CAgg creation --- @@ -842,128 +843,128 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:372: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:373: NOTICE: refreshing continuous aggregate "cagg_4_hours" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours | public.time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours | time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours; -psql:include/cagg_query_common.sql:374: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk +psql:include/cagg_query_common.sql:375: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:380: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:381: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset; -psql:include/cagg_query_common.sql:382: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk +psql:include/cagg_query_common.sql:383: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:388: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" +psql:include/cagg_query_common.sql:389: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset2 | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset2 | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset2; -psql:include/cagg_query_common.sql:390: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk +psql:include/cagg_query_common.sql:391: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk -- Variable buckets (timezone is provided) with offset CREATE MATERIALIZED VIEW cagg_4_hours_offset_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:397: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" +psql:include/cagg_query_common.sql:398: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_ts; -psql:include/cagg_query_common.sql:399: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk +psql:include/cagg_query_common.sql:400: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:405: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:406: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin; -psql:include/cagg_query_common.sql:407: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk +psql:include/cagg_query_common.sql:408: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk -- Using named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:414: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" +psql:include/cagg_query_common.sql:415: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin2 | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin2 | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin2; -psql:include/cagg_query_common.sql:416: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk +psql:include/cagg_query_common.sql:417: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:423: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" +psql:include/cagg_query_common.sql:424: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts; -psql:include/cagg_query_common.sql:425: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk +psql:include/cagg_query_common.sql:426: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk -- Without named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, 'UTC', '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:432: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" +psql:include/cagg_query_common.sql:433: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts2; -psql:include/cagg_query_common.sql:434: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk +psql:include/cagg_query_common.sql:435: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk -- Timestamp based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:441: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" +psql:include/cagg_query_common.sql:442: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+----------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_wo_tz | public.time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+---------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_wo_tz | time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t (1 row) CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz @@ -971,169 +972,169 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:448: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" +psql:include/cagg_query_common.sql:449: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz; -psql:include/cagg_query_common.sql:450: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk +psql:include/cagg_query_common.sql:451: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:457: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" +psql:include/cagg_query_common.sql:458: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz2 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz2 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2; -psql:include/cagg_query_common.sql:459: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk +psql:include/cagg_query_common.sql:460: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:465: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" +psql:include/cagg_query_common.sql:466: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+-------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_wo_tz | public.time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_wo_tz | time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_wo_tz; -psql:include/cagg_query_common.sql:467: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk +psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk DROP MATERIALIZED VIEW cagg_4_hours_wo_tz; -psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk +psql:include/cagg_query_common.sql:469: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk -- Date based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_date WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:475: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" +psql:include/cagg_query_common.sql:476: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------+----------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date | public.time_bucket(interval,pg_catalog.date) | @ 4 days | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date | time_bucket(interval,date) | @ 4 days | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date; -psql:include/cagg_query_common.sql:477: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk +psql:include/cagg_query_common.sql:478: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, '2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:483: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" +psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin; -psql:include/cagg_query_common.sql:485: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk +psql:include/cagg_query_common.sql:486: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, origin=>'2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:491: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" +psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin2 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin2; -psql:include/cagg_query_common.sql:493: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk +psql:include/cagg_query_common.sql:494: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, "offset"=>'30m'::interval), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:499: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" +psql:include/cagg_query_common.sql:500: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_offset | public.time_bucket(interval,pg_catalog.date,interval) | @ 4 days | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_offset | time_bucket(interval,date,interval) | @ 4 days | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_offset; -psql:include/cagg_query_common.sql:501: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk +psql:include/cagg_query_common.sql:502: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk -- Integer based CAggs CREATE MATERIALIZED VIEW cagg_smallint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:508: NOTICE: refreshing continuous aggregate "cagg_smallint" +psql:include/cagg_query_common.sql:509: NOTICE: refreshing continuous aggregate "cagg_smallint" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+---------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint | public.time_bucket(smallint,smallint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+--------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint | time_bucket(smallint,smallint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint; -psql:include/cagg_query_common.sql:510: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk +psql:include/cagg_query_common.sql:511: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk CREATE MATERIALIZED VIEW cagg_smallint_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::smallint), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:516: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" +psql:include/cagg_query_common.sql:517: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint_offset | public.time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-----------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint_offset | time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint_offset; -psql:include/cagg_query_common.sql:518: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk +psql:include/cagg_query_common.sql:519: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk CREATE MATERIALIZED VIEW cagg_int WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:524: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:525: NOTICE: refreshing continuous aggregate "cagg_int" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int | public.time_bucket(integer,integer) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int | time_bucket(integer,integer) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_int; -psql:include/cagg_query_common.sql:526: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk +psql:include/cagg_query_common.sql:527: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::int), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:532: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:533: NOTICE: refreshing continuous aggregate "cagg_int_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-----------------+---------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int_offset | public.time_bucket(integer,integer,integer) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-----------------+--------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int_offset | time_bucket(integer,integer,integer) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_int_offset; -psql:include/cagg_query_common.sql:534: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk +psql:include/cagg_query_common.sql:535: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk CREATE MATERIALIZED VIEW cagg_bigint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint | public.time_bucket(bigint,bigint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint | time_bucket(bigint,bigint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint; @@ -1143,9 +1144,9 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint_offset; @@ -1156,22 +1157,11 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset2 FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset2 | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset2 | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) --- mess with the bucket_func signature to make sure it will raise an exception -SET ROLE :ROLE_CLUSTER_SUPERUSER; -\set ON_ERROR_STOP 0 -BEGIN; -UPDATE _timescaledb_catalog.continuous_aggs_bucket_function SET bucket_func = 'func_does_not_exist()'; --- should error because function does not exist -CALL refresh_continuous_aggregate('cagg_bigint_offset2', NULL, NULL); -psql:include/cagg_query_common.sql:566: ERROR: function "func_does_not_exist()" does not exist -ROLLBACK; -\set ON_ERROR_STOP 1 -SET ROLE :ROLE_DEFAULT_PERM_USER; DROP MATERIALIZED VIEW cagg_bigint_offset2; -- Test invalid bucket definitions \set ON_ERROR_STOP 0 @@ -1181,14 +1171,14 @@ CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:580: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 +psql:include/cagg_query_common.sql:570: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 -- Offset and origin at the same time is not allowed (function does exists but invalid parameter combination) CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:587: ERROR: using offset and origin in a time_bucket function at the same time is not supported +psql:include/cagg_query_common.sql:577: ERROR: using offset and origin in a time_bucket function at the same time is not supported \set ON_ERROR_STOP 1 --- -- Tests with CAgg processing @@ -1215,20 +1205,20 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:613: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:603: NOTICE: refreshing continuous aggregate "cagg_4_hours" CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:619: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:609: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" -- Align origin with first value CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:626: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:616: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" -- Query the CAggs and check that all buckets are materialized SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; time_bucket | max @@ -1537,24 +1527,24 @@ SELECT * FROM cagg_4_hours_origin; -- Update materialized data SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] -psql:include/cagg_query_common.sql:683: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:683: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:673: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:673: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] +psql:include/cagg_query_common.sql:673: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:673: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:684: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] -psql:include/cagg_query_common.sql:684: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:684: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:674: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:674: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] +psql:include/cagg_query_common.sql:674: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:685: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] -psql:include/cagg_query_common.sql:685: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:685: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:675: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:675: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] +psql:include/cagg_query_common.sql:675: LOG: deleted 1 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" RESET client_min_messages; -psql:include/cagg_query_common.sql:686: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:676: LOG: statement: RESET client_min_messages; -- Query the CAggs and check that all buckets are materialized SELECT * FROM cagg_4_hours; time_bucket | max @@ -1757,40 +1747,40 @@ INSERT INTO temperature values('2020-01-02 01:35:00+01', 5555); INSERT INTO temperature values('2020-01-02 05:05:00+01', 8888); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] -psql:include/cagg_query_common.sql:725: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] -psql:include/cagg_query_common.sql:725: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] +psql:include/cagg_query_common.sql:715: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] +psql:include/cagg_query_common.sql:715: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] -psql:include/cagg_query_common.sql:726: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] -psql:include/cagg_query_common.sql:726: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 +psql:include/cagg_query_common.sql:716: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] +psql:include/cagg_query_common.sql:716: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] +psql:include/cagg_query_common.sql:716: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] -psql:include/cagg_query_common.sql:727: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] -psql:include/cagg_query_common.sql:727: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 +psql:include/cagg_query_common.sql:717: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] +psql:include/cagg_query_common.sql:717: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] +psql:include/cagg_query_common.sql:717: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 RESET client_min_messages; -psql:include/cagg_query_common.sql:728: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:718: LOG: statement: RESET client_min_messages; ALTER MATERIALIZED VIEW cagg_4_hours SET (timescaledb.materialized_only=true); SELECT * FROM cagg_4_hours; time_bucket | max @@ -1986,7 +1976,7 @@ CREATE MATERIALIZED VIEW cagg_1_year SELECT time_bucket('1 year', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:766: NOTICE: refreshing continuous aggregate "cagg_1_year" +psql:include/cagg_query_common.sql:756: NOTICE: refreshing continuous aggregate "cagg_1_year" SELECT * FROM _timescaledb_catalog.continuous_aggs_materialization_invalidation_log ORDER BY 1, 2, 3; materialization_id | lowest_modified_value | greatest_modified_value --------------------+-----------------------+------------------------- @@ -2018,13 +2008,13 @@ CREATE MATERIALIZED VIEW cagg_int AS SELECT time_bucket('10', time), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:783: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:773: NOTICE: refreshing continuous aggregate "cagg_int" CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>5), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:789: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:779: NOTICE: refreshing continuous aggregate "cagg_int_offset" -- Compare bucketing results SELECT time_bucket('10', time), SUM(data) FROM table_int GROUP BY 1 ORDER BY 1; time_bucket | sum @@ -2239,14 +2229,14 @@ SELECT * FROM cagg_int_offset; INSERT INTO table_int VALUES(114, 0); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] -psql:include/cagg_query_common.sql:824: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_38" -psql:include/cagg_query_common.sql:824: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially -psql:include/cagg_query_common.sql:824: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication -psql:include/cagg_query_common.sql:824: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" +psql:include/cagg_query_common.sql:814: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); +psql:include/cagg_query_common.sql:814: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] +psql:include/cagg_query_common.sql:814: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_38" +psql:include/cagg_query_common.sql:814: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially +psql:include/cagg_query_common.sql:814: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication +psql:include/cagg_query_common.sql:814: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" RESET client_min_messages; -psql:include/cagg_query_common.sql:825: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:815: LOG: statement: RESET client_min_messages; SELECT * FROM cagg_int_offset; time_bucket | value -------------+------- @@ -2289,45 +2279,45 @@ CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin SELECT time_bucket('1 year', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:835: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" +psql:include/cagg_query_common.sql:825: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin; -psql:include/cagg_query_common.sql:837: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:827: NOTICE: drop cascades to 2 other objects -- Variable due to the used timezone CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2 WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:844: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" +psql:include/cagg_query_common.sql:834: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2; -psql:include/cagg_query_common.sql:846: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:836: NOTICE: drop cascades to 2 other objects -- Variable with offset CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3 WITH (timescaledb.continuous) AS SELECT time_bucket('1 year', time, "offset"=>'5 minutes'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:853: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" +psql:include/cagg_query_common.sql:843: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin3'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin3 | public.time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin3 | time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3; -psql:include/cagg_query_common.sql:855: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:845: NOTICE: drop cascades to 2 other objects --- -- Test with blocking a few broken configurations --- @@ -2340,26 +2330,26 @@ CREATE MATERIALIZED VIEW cagg_1_hour_origin SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:870: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" +psql:include/cagg_query_common.sql:860: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" CREATE MATERIALIZED VIEW cagg_1_week_origin WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, origin=>'2022-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_origin GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:876: ERROR: cannot create continuous aggregate with different bucket origin values +psql:include/cagg_query_common.sql:866: ERROR: cannot create continuous aggregate with different bucket origin values -- Different time offset CREATE MATERIALIZED VIEW cagg_1_hour_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, "offset"=>'30m'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:883: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:873: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" CREATE MATERIALIZED VIEW cagg_1_week_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:889: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:879: ERROR: cannot create continuous aggregate with different bucket offset values -- Cagg with NULL offset on top of cagg with non-NULL offset \set VERBOSITY default CREATE MATERIALIZED VIEW cagg_1_week_null_offset @@ -2367,7 +2357,7 @@ CREATE MATERIALIZED VIEW cagg_1_week_null_offset SELECT time_bucket('1 week', hour_bucket, "offset"=>NULL::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:897: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:887: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_null_offset" [NULL] and "public.cagg_1_hour_offset" [@ 30 mins] should be the same. -- Cagg with non-NULL offset on top of cagg with NULL offset CREATE MATERIALIZED VIEW cagg_1_hour_null_offset @@ -2375,14 +2365,14 @@ CREATE MATERIALIZED VIEW cagg_1_hour_null_offset SELECT time_bucket('1 hour', time, "offset"=>NULL::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:904: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" +psql:include/cagg_query_common.sql:894: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" HINT: Use WITH NO DATA if you do not want to refresh the continuous aggregate on creation. CREATE MATERIALIZED VIEW cagg_1_week_non_null_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_null_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:910: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:900: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_non_null_offset" [@ 35 mins] and "public.cagg_1_hour_null_offset" [NULL] should be the same. \set VERBOSITY terse -- Different integer offset @@ -2391,20 +2381,20 @@ CREATE MATERIALIZED VIEW cagg_int_offset_5 AS SELECT time_bucket('10', time, "offset"=>5) AS time, SUM(data) AS value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:918: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" +psql:include/cagg_query_common.sql:908: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" CREATE MATERIALIZED VIEW cagg_int_offset_10 WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>10) AS time, SUM(value) AS value FROM cagg_int_offset_5 GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:924: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:914: ERROR: cannot create continuous aggregate with different bucket offset values \set ON_ERROR_STOP 1 DROP MATERIALIZED VIEW cagg_1_hour_origin; -psql:include/cagg_query_common.sql:928: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:918: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_1_hour_offset; -psql:include/cagg_query_common.sql:929: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:919: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_int_offset_5; -psql:include/cagg_query_common.sql:930: NOTICE: drop cascades to 3 other objects +psql:include/cagg_query_common.sql:920: NOTICE: drop cascades to 3 other objects --- -- CAGGs on CAGGs tests --- @@ -2413,11 +2403,11 @@ CREATE MATERIALIZED VIEW cagg_1_hour_offset SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:939: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:929: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) CREATE MATERIALIZED VIEW cagg_1_week_offset @@ -2425,11 +2415,11 @@ CREATE MATERIALIZED VIEW cagg_1_week_offset SELECT time_bucket('1 week', hour_bucket, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:946: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" +psql:include/cagg_query_common.sql:936: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_week_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_week_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_week_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) -- Compare output diff --git a/tsl/test/expected/cagg_query_using_merge-15.out b/tsl/test/expected/cagg_query_using_merge-15.out index 682d3aaae4c..415474f68cc 100644 --- a/tsl/test/expected/cagg_query_using_merge-15.out +++ b/tsl/test/expected/cagg_query_using_merge-15.out @@ -13,6 +13,7 @@ SET timescaledb.enable_merge_on_cagg_refresh TO ON; -- This file and its contents are licensed under the Timescale License. -- Please see the included NOTICE for copyright information and -- LICENSE-TIMESCALE for a copy of the license. +\set TEST_BASE_NAME cagg_query SELECT format('%s/results/%s_results_view.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW", format('%s/results/%s_results_view_hashagg.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW_HASHAGG", @@ -763,7 +764,7 @@ CREATE TABLE temperature_wo_tz ( value float ); SELECT create_hypertable('temperature_wo_tz', 'time'); -psql:include/cagg_query_common.sql:316: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices +psql:include/cagg_query_common.sql:317: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices create_hypertable -------------------------------- (5,public,temperature_wo_tz,t) @@ -795,21 +796,21 @@ CREATE TABLE table_bigint ( data bigint ); SELECT create_hypertable('table_smallint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:345: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" create_hypertable ----------------------------- (7,public,table_smallint,t) (1 row) SELECT create_hypertable('table_int', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" create_hypertable ------------------------ (8,public,table_int,t) (1 row) SELECT create_hypertable('table_bigint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:348: NOTICE: adding not-null constraint to column "time" create_hypertable --------------------------- (9,public,table_bigint,t) @@ -841,7 +842,7 @@ INSERT INTO table_int VALUES(1,2); INSERT INTO table_bigint VALUES(1,2); CREATE VIEW caggs_info AS SELECT user_view_schema, user_view_name, bucket_func, bucket_width, bucket_origin, bucket_offset, bucket_timezone, bucket_fixed_width -FROM _timescaledb_catalog.continuous_aggs_bucket_function NATURAL JOIN _timescaledb_catalog.continuous_agg; +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id); --- -- Tests with CAgg creation --- @@ -850,128 +851,128 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:372: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:373: NOTICE: refreshing continuous aggregate "cagg_4_hours" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours | public.time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours | time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours; -psql:include/cagg_query_common.sql:374: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk +psql:include/cagg_query_common.sql:375: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:380: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:381: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset; -psql:include/cagg_query_common.sql:382: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk +psql:include/cagg_query_common.sql:383: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:388: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" +psql:include/cagg_query_common.sql:389: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset2 | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset2 | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset2; -psql:include/cagg_query_common.sql:390: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk +psql:include/cagg_query_common.sql:391: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk -- Variable buckets (timezone is provided) with offset CREATE MATERIALIZED VIEW cagg_4_hours_offset_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:397: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" +psql:include/cagg_query_common.sql:398: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_ts; -psql:include/cagg_query_common.sql:399: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk +psql:include/cagg_query_common.sql:400: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:405: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:406: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin; -psql:include/cagg_query_common.sql:407: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk +psql:include/cagg_query_common.sql:408: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk -- Using named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:414: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" +psql:include/cagg_query_common.sql:415: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin2 | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin2 | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin2; -psql:include/cagg_query_common.sql:416: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk +psql:include/cagg_query_common.sql:417: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:423: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" +psql:include/cagg_query_common.sql:424: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts; -psql:include/cagg_query_common.sql:425: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk +psql:include/cagg_query_common.sql:426: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk -- Without named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, 'UTC', '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:432: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" +psql:include/cagg_query_common.sql:433: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts2; -psql:include/cagg_query_common.sql:434: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk +psql:include/cagg_query_common.sql:435: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk -- Timestamp based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:441: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" +psql:include/cagg_query_common.sql:442: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+----------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_wo_tz | public.time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+---------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_wo_tz | time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t (1 row) CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz @@ -979,169 +980,169 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:448: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" +psql:include/cagg_query_common.sql:449: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz; -psql:include/cagg_query_common.sql:450: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk +psql:include/cagg_query_common.sql:451: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:457: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" +psql:include/cagg_query_common.sql:458: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz2 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz2 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2; -psql:include/cagg_query_common.sql:459: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk +psql:include/cagg_query_common.sql:460: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:465: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" +psql:include/cagg_query_common.sql:466: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+-------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_wo_tz | public.time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_wo_tz | time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_wo_tz; -psql:include/cagg_query_common.sql:467: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk +psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk DROP MATERIALIZED VIEW cagg_4_hours_wo_tz; -psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk +psql:include/cagg_query_common.sql:469: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk -- Date based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_date WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:475: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" +psql:include/cagg_query_common.sql:476: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------+----------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date | public.time_bucket(interval,pg_catalog.date) | @ 4 days | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date | time_bucket(interval,date) | @ 4 days | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date; -psql:include/cagg_query_common.sql:477: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk +psql:include/cagg_query_common.sql:478: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, '2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:483: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" +psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin; -psql:include/cagg_query_common.sql:485: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk +psql:include/cagg_query_common.sql:486: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, origin=>'2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:491: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" +psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin2 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin2; -psql:include/cagg_query_common.sql:493: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk +psql:include/cagg_query_common.sql:494: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, "offset"=>'30m'::interval), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:499: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" +psql:include/cagg_query_common.sql:500: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_offset | public.time_bucket(interval,pg_catalog.date,interval) | @ 4 days | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_offset | time_bucket(interval,date,interval) | @ 4 days | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_offset; -psql:include/cagg_query_common.sql:501: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk +psql:include/cagg_query_common.sql:502: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk -- Integer based CAggs CREATE MATERIALIZED VIEW cagg_smallint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:508: NOTICE: refreshing continuous aggregate "cagg_smallint" +psql:include/cagg_query_common.sql:509: NOTICE: refreshing continuous aggregate "cagg_smallint" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+---------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint | public.time_bucket(smallint,smallint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+--------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint | time_bucket(smallint,smallint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint; -psql:include/cagg_query_common.sql:510: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk +psql:include/cagg_query_common.sql:511: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk CREATE MATERIALIZED VIEW cagg_smallint_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::smallint), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:516: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" +psql:include/cagg_query_common.sql:517: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint_offset | public.time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-----------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint_offset | time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint_offset; -psql:include/cagg_query_common.sql:518: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk +psql:include/cagg_query_common.sql:519: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk CREATE MATERIALIZED VIEW cagg_int WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:524: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:525: NOTICE: refreshing continuous aggregate "cagg_int" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int | public.time_bucket(integer,integer) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int | time_bucket(integer,integer) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_int; -psql:include/cagg_query_common.sql:526: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk +psql:include/cagg_query_common.sql:527: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::int), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:532: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:533: NOTICE: refreshing continuous aggregate "cagg_int_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-----------------+---------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int_offset | public.time_bucket(integer,integer,integer) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-----------------+--------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int_offset | time_bucket(integer,integer,integer) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_int_offset; -psql:include/cagg_query_common.sql:534: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk +psql:include/cagg_query_common.sql:535: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk CREATE MATERIALIZED VIEW cagg_bigint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint | public.time_bucket(bigint,bigint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint | time_bucket(bigint,bigint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint; @@ -1151,9 +1152,9 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint_offset; @@ -1164,22 +1165,11 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset2 FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset2 | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset2 | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) --- mess with the bucket_func signature to make sure it will raise an exception -SET ROLE :ROLE_CLUSTER_SUPERUSER; -\set ON_ERROR_STOP 0 -BEGIN; -UPDATE _timescaledb_catalog.continuous_aggs_bucket_function SET bucket_func = 'func_does_not_exist()'; --- should error because function does not exist -CALL refresh_continuous_aggregate('cagg_bigint_offset2', NULL, NULL); -psql:include/cagg_query_common.sql:566: ERROR: function "func_does_not_exist()" does not exist -ROLLBACK; -\set ON_ERROR_STOP 1 -SET ROLE :ROLE_DEFAULT_PERM_USER; DROP MATERIALIZED VIEW cagg_bigint_offset2; -- Test invalid bucket definitions \set ON_ERROR_STOP 0 @@ -1189,14 +1179,14 @@ CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:580: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 +psql:include/cagg_query_common.sql:570: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 -- Offset and origin at the same time is not allowed (function does exists but invalid parameter combination) CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:587: ERROR: using offset and origin in a time_bucket function at the same time is not supported +psql:include/cagg_query_common.sql:577: ERROR: using offset and origin in a time_bucket function at the same time is not supported \set ON_ERROR_STOP 1 --- -- Tests with CAgg processing @@ -1223,20 +1213,20 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:613: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:603: NOTICE: refreshing continuous aggregate "cagg_4_hours" CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:619: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:609: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" -- Align origin with first value CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:626: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:616: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" -- Query the CAggs and check that all buckets are materialized SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; time_bucket | max @@ -1545,23 +1535,23 @@ SELECT * FROM cagg_4_hours_origin; -- Update materialized data SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] -psql:include/cagg_query_common.sql:683: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:673: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:673: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] +psql:include/cagg_query_common.sql:673: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:684: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] -psql:include/cagg_query_common.sql:684: LOG: merged 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:684: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:674: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:674: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] +psql:include/cagg_query_common.sql:674: LOG: merged 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:685: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] -psql:include/cagg_query_common.sql:685: LOG: merged 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:685: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:675: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:675: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] +psql:include/cagg_query_common.sql:675: LOG: merged 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" RESET client_min_messages; -psql:include/cagg_query_common.sql:686: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:676: LOG: statement: RESET client_min_messages; -- Query the CAggs and check that all buckets are materialized SELECT * FROM cagg_4_hours; time_bucket | max @@ -1764,34 +1754,34 @@ INSERT INTO temperature values('2020-01-02 01:35:00+01', 5555); INSERT INTO temperature values('2020-01-02 05:05:00+01', 8888); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] -psql:include/cagg_query_common.sql:726: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] -psql:include/cagg_query_common.sql:726: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 +psql:include/cagg_query_common.sql:716: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] +psql:include/cagg_query_common.sql:716: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] +psql:include/cagg_query_common.sql:716: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] -psql:include/cagg_query_common.sql:727: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] -psql:include/cagg_query_common.sql:727: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 +psql:include/cagg_query_common.sql:717: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] +psql:include/cagg_query_common.sql:717: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] +psql:include/cagg_query_common.sql:717: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 RESET client_min_messages; -psql:include/cagg_query_common.sql:728: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:718: LOG: statement: RESET client_min_messages; ALTER MATERIALIZED VIEW cagg_4_hours SET (timescaledb.materialized_only=true); SELECT * FROM cagg_4_hours; time_bucket | max @@ -1987,7 +1977,7 @@ CREATE MATERIALIZED VIEW cagg_1_year SELECT time_bucket('1 year', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:766: NOTICE: refreshing continuous aggregate "cagg_1_year" +psql:include/cagg_query_common.sql:756: NOTICE: refreshing continuous aggregate "cagg_1_year" SELECT * FROM _timescaledb_catalog.continuous_aggs_materialization_invalidation_log ORDER BY 1, 2, 3; materialization_id | lowest_modified_value | greatest_modified_value --------------------+-----------------------+------------------------- @@ -2019,13 +2009,13 @@ CREATE MATERIALIZED VIEW cagg_int AS SELECT time_bucket('10', time), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:783: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:773: NOTICE: refreshing continuous aggregate "cagg_int" CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>5), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:789: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:779: NOTICE: refreshing continuous aggregate "cagg_int_offset" -- Compare bucketing results SELECT time_bucket('10', time), SUM(data) FROM table_int GROUP BY 1 ORDER BY 1; time_bucket | sum @@ -2240,13 +2230,13 @@ SELECT * FROM cagg_int_offset; INSERT INTO table_int VALUES(114, 0); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] -psql:include/cagg_query_common.sql:824: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially -psql:include/cagg_query_common.sql:824: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication -psql:include/cagg_query_common.sql:824: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" +psql:include/cagg_query_common.sql:814: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); +psql:include/cagg_query_common.sql:814: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] +psql:include/cagg_query_common.sql:814: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially +psql:include/cagg_query_common.sql:814: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication +psql:include/cagg_query_common.sql:814: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" RESET client_min_messages; -psql:include/cagg_query_common.sql:825: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:815: LOG: statement: RESET client_min_messages; SELECT * FROM cagg_int_offset; time_bucket | value -------------+------- @@ -2289,45 +2279,45 @@ CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin SELECT time_bucket('1 year', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:835: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" +psql:include/cagg_query_common.sql:825: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin; -psql:include/cagg_query_common.sql:837: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:827: NOTICE: drop cascades to 2 other objects -- Variable due to the used timezone CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2 WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:844: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" +psql:include/cagg_query_common.sql:834: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2; -psql:include/cagg_query_common.sql:846: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:836: NOTICE: drop cascades to 2 other objects -- Variable with offset CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3 WITH (timescaledb.continuous) AS SELECT time_bucket('1 year', time, "offset"=>'5 minutes'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:853: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" +psql:include/cagg_query_common.sql:843: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin3'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin3 | public.time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin3 | time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3; -psql:include/cagg_query_common.sql:855: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:845: NOTICE: drop cascades to 2 other objects --- -- Test with blocking a few broken configurations --- @@ -2340,26 +2330,26 @@ CREATE MATERIALIZED VIEW cagg_1_hour_origin SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:870: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" +psql:include/cagg_query_common.sql:860: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" CREATE MATERIALIZED VIEW cagg_1_week_origin WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, origin=>'2022-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_origin GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:876: ERROR: cannot create continuous aggregate with different bucket origin values +psql:include/cagg_query_common.sql:866: ERROR: cannot create continuous aggregate with different bucket origin values -- Different time offset CREATE MATERIALIZED VIEW cagg_1_hour_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, "offset"=>'30m'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:883: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:873: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" CREATE MATERIALIZED VIEW cagg_1_week_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:889: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:879: ERROR: cannot create continuous aggregate with different bucket offset values -- Cagg with NULL offset on top of cagg with non-NULL offset \set VERBOSITY default CREATE MATERIALIZED VIEW cagg_1_week_null_offset @@ -2367,7 +2357,7 @@ CREATE MATERIALIZED VIEW cagg_1_week_null_offset SELECT time_bucket('1 week', hour_bucket, "offset"=>NULL::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:897: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:887: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_null_offset" [NULL] and "public.cagg_1_hour_offset" [@ 30 mins] should be the same. -- Cagg with non-NULL offset on top of cagg with NULL offset CREATE MATERIALIZED VIEW cagg_1_hour_null_offset @@ -2375,14 +2365,14 @@ CREATE MATERIALIZED VIEW cagg_1_hour_null_offset SELECT time_bucket('1 hour', time, "offset"=>NULL::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:904: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" +psql:include/cagg_query_common.sql:894: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" HINT: Use WITH NO DATA if you do not want to refresh the continuous aggregate on creation. CREATE MATERIALIZED VIEW cagg_1_week_non_null_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_null_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:910: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:900: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_non_null_offset" [@ 35 mins] and "public.cagg_1_hour_null_offset" [NULL] should be the same. \set VERBOSITY terse -- Different integer offset @@ -2391,20 +2381,20 @@ CREATE MATERIALIZED VIEW cagg_int_offset_5 AS SELECT time_bucket('10', time, "offset"=>5) AS time, SUM(data) AS value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:918: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" +psql:include/cagg_query_common.sql:908: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" CREATE MATERIALIZED VIEW cagg_int_offset_10 WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>10) AS time, SUM(value) AS value FROM cagg_int_offset_5 GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:924: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:914: ERROR: cannot create continuous aggregate with different bucket offset values \set ON_ERROR_STOP 1 DROP MATERIALIZED VIEW cagg_1_hour_origin; -psql:include/cagg_query_common.sql:928: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:918: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_1_hour_offset; -psql:include/cagg_query_common.sql:929: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:919: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_int_offset_5; -psql:include/cagg_query_common.sql:930: NOTICE: drop cascades to 3 other objects +psql:include/cagg_query_common.sql:920: NOTICE: drop cascades to 3 other objects --- -- CAGGs on CAGGs tests --- @@ -2413,11 +2403,11 @@ CREATE MATERIALIZED VIEW cagg_1_hour_offset SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:939: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:929: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) CREATE MATERIALIZED VIEW cagg_1_week_offset @@ -2425,11 +2415,11 @@ CREATE MATERIALIZED VIEW cagg_1_week_offset SELECT time_bucket('1 week', hour_bucket, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:946: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" +psql:include/cagg_query_common.sql:936: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_week_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_week_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_week_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) -- Compare output diff --git a/tsl/test/expected/cagg_query_using_merge-16.out b/tsl/test/expected/cagg_query_using_merge-16.out index 71bf6d60a91..c5b3081df31 100644 --- a/tsl/test/expected/cagg_query_using_merge-16.out +++ b/tsl/test/expected/cagg_query_using_merge-16.out @@ -13,6 +13,7 @@ SET timescaledb.enable_merge_on_cagg_refresh TO ON; -- This file and its contents are licensed under the Timescale License. -- Please see the included NOTICE for copyright information and -- LICENSE-TIMESCALE for a copy of the license. +\set TEST_BASE_NAME cagg_query SELECT format('%s/results/%s_results_view.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW", format('%s/results/%s_results_view_hashagg.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW_HASHAGG", @@ -757,7 +758,7 @@ CREATE TABLE temperature_wo_tz ( value float ); SELECT create_hypertable('temperature_wo_tz', 'time'); -psql:include/cagg_query_common.sql:316: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices +psql:include/cagg_query_common.sql:317: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices create_hypertable -------------------------------- (5,public,temperature_wo_tz,t) @@ -789,21 +790,21 @@ CREATE TABLE table_bigint ( data bigint ); SELECT create_hypertable('table_smallint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:345: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" create_hypertable ----------------------------- (7,public,table_smallint,t) (1 row) SELECT create_hypertable('table_int', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" create_hypertable ------------------------ (8,public,table_int,t) (1 row) SELECT create_hypertable('table_bigint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:348: NOTICE: adding not-null constraint to column "time" create_hypertable --------------------------- (9,public,table_bigint,t) @@ -835,7 +836,7 @@ INSERT INTO table_int VALUES(1,2); INSERT INTO table_bigint VALUES(1,2); CREATE VIEW caggs_info AS SELECT user_view_schema, user_view_name, bucket_func, bucket_width, bucket_origin, bucket_offset, bucket_timezone, bucket_fixed_width -FROM _timescaledb_catalog.continuous_aggs_bucket_function NATURAL JOIN _timescaledb_catalog.continuous_agg; +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id); --- -- Tests with CAgg creation --- @@ -844,128 +845,128 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:372: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:373: NOTICE: refreshing continuous aggregate "cagg_4_hours" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours | public.time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours | time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours; -psql:include/cagg_query_common.sql:374: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk +psql:include/cagg_query_common.sql:375: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:380: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:381: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset; -psql:include/cagg_query_common.sql:382: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk +psql:include/cagg_query_common.sql:383: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:388: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" +psql:include/cagg_query_common.sql:389: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset2 | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset2 | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset2; -psql:include/cagg_query_common.sql:390: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk +psql:include/cagg_query_common.sql:391: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk -- Variable buckets (timezone is provided) with offset CREATE MATERIALIZED VIEW cagg_4_hours_offset_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:397: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" +psql:include/cagg_query_common.sql:398: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_ts; -psql:include/cagg_query_common.sql:399: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk +psql:include/cagg_query_common.sql:400: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:405: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:406: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin; -psql:include/cagg_query_common.sql:407: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk +psql:include/cagg_query_common.sql:408: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk -- Using named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:414: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" +psql:include/cagg_query_common.sql:415: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin2 | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin2 | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin2; -psql:include/cagg_query_common.sql:416: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk +psql:include/cagg_query_common.sql:417: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:423: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" +psql:include/cagg_query_common.sql:424: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts; -psql:include/cagg_query_common.sql:425: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk +psql:include/cagg_query_common.sql:426: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk -- Without named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, 'UTC', '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:432: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" +psql:include/cagg_query_common.sql:433: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts2; -psql:include/cagg_query_common.sql:434: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk +psql:include/cagg_query_common.sql:435: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk -- Timestamp based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:441: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" +psql:include/cagg_query_common.sql:442: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+----------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_wo_tz | public.time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+---------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_wo_tz | time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t (1 row) CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz @@ -973,169 +974,169 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:448: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" +psql:include/cagg_query_common.sql:449: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz; -psql:include/cagg_query_common.sql:450: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk +psql:include/cagg_query_common.sql:451: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:457: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" +psql:include/cagg_query_common.sql:458: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz2 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz2 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2; -psql:include/cagg_query_common.sql:459: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk +psql:include/cagg_query_common.sql:460: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:465: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" +psql:include/cagg_query_common.sql:466: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+-------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_wo_tz | public.time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_wo_tz | time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_wo_tz; -psql:include/cagg_query_common.sql:467: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk +psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk DROP MATERIALIZED VIEW cagg_4_hours_wo_tz; -psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk +psql:include/cagg_query_common.sql:469: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk -- Date based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_date WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:475: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" +psql:include/cagg_query_common.sql:476: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------+----------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date | public.time_bucket(interval,pg_catalog.date) | @ 4 days | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date | time_bucket(interval,date) | @ 4 days | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date; -psql:include/cagg_query_common.sql:477: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk +psql:include/cagg_query_common.sql:478: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, '2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:483: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" +psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin; -psql:include/cagg_query_common.sql:485: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk +psql:include/cagg_query_common.sql:486: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, origin=>'2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:491: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" +psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin2 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin2; -psql:include/cagg_query_common.sql:493: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk +psql:include/cagg_query_common.sql:494: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, "offset"=>'30m'::interval), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:499: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" +psql:include/cagg_query_common.sql:500: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_offset | public.time_bucket(interval,pg_catalog.date,interval) | @ 4 days | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_offset | time_bucket(interval,date,interval) | @ 4 days | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_offset; -psql:include/cagg_query_common.sql:501: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk +psql:include/cagg_query_common.sql:502: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk -- Integer based CAggs CREATE MATERIALIZED VIEW cagg_smallint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:508: NOTICE: refreshing continuous aggregate "cagg_smallint" +psql:include/cagg_query_common.sql:509: NOTICE: refreshing continuous aggregate "cagg_smallint" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+---------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint | public.time_bucket(smallint,smallint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+--------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint | time_bucket(smallint,smallint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint; -psql:include/cagg_query_common.sql:510: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk +psql:include/cagg_query_common.sql:511: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk CREATE MATERIALIZED VIEW cagg_smallint_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::smallint), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:516: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" +psql:include/cagg_query_common.sql:517: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint_offset | public.time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-----------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint_offset | time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint_offset; -psql:include/cagg_query_common.sql:518: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk +psql:include/cagg_query_common.sql:519: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk CREATE MATERIALIZED VIEW cagg_int WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:524: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:525: NOTICE: refreshing continuous aggregate "cagg_int" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int | public.time_bucket(integer,integer) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int | time_bucket(integer,integer) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_int; -psql:include/cagg_query_common.sql:526: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk +psql:include/cagg_query_common.sql:527: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::int), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:532: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:533: NOTICE: refreshing continuous aggregate "cagg_int_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-----------------+---------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int_offset | public.time_bucket(integer,integer,integer) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-----------------+--------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int_offset | time_bucket(integer,integer,integer) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_int_offset; -psql:include/cagg_query_common.sql:534: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk +psql:include/cagg_query_common.sql:535: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk CREATE MATERIALIZED VIEW cagg_bigint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint | public.time_bucket(bigint,bigint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint | time_bucket(bigint,bigint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint; @@ -1145,9 +1146,9 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint_offset; @@ -1158,22 +1159,11 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset2 FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset2 | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset2 | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) --- mess with the bucket_func signature to make sure it will raise an exception -SET ROLE :ROLE_CLUSTER_SUPERUSER; -\set ON_ERROR_STOP 0 -BEGIN; -UPDATE _timescaledb_catalog.continuous_aggs_bucket_function SET bucket_func = 'func_does_not_exist()'; --- should error because function does not exist -CALL refresh_continuous_aggregate('cagg_bigint_offset2', NULL, NULL); -psql:include/cagg_query_common.sql:566: ERROR: function "func_does_not_exist()" does not exist -ROLLBACK; -\set ON_ERROR_STOP 1 -SET ROLE :ROLE_DEFAULT_PERM_USER; DROP MATERIALIZED VIEW cagg_bigint_offset2; -- Test invalid bucket definitions \set ON_ERROR_STOP 0 @@ -1183,14 +1173,14 @@ CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:580: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 +psql:include/cagg_query_common.sql:570: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 -- Offset and origin at the same time is not allowed (function does exists but invalid parameter combination) CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:587: ERROR: using offset and origin in a time_bucket function at the same time is not supported +psql:include/cagg_query_common.sql:577: ERROR: using offset and origin in a time_bucket function at the same time is not supported \set ON_ERROR_STOP 1 --- -- Tests with CAgg processing @@ -1217,20 +1207,20 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:613: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:603: NOTICE: refreshing continuous aggregate "cagg_4_hours" CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:619: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:609: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" -- Align origin with first value CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:626: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:616: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" -- Query the CAggs and check that all buckets are materialized SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; time_bucket | max @@ -1539,23 +1529,23 @@ SELECT * FROM cagg_4_hours_origin; -- Update materialized data SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] -psql:include/cagg_query_common.sql:683: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:673: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:673: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] +psql:include/cagg_query_common.sql:673: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:684: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] -psql:include/cagg_query_common.sql:684: LOG: merged 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:684: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:674: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:674: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] +psql:include/cagg_query_common.sql:674: LOG: merged 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:685: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] -psql:include/cagg_query_common.sql:685: LOG: merged 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:685: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:675: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:675: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] +psql:include/cagg_query_common.sql:675: LOG: merged 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" RESET client_min_messages; -psql:include/cagg_query_common.sql:686: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:676: LOG: statement: RESET client_min_messages; -- Query the CAggs and check that all buckets are materialized SELECT * FROM cagg_4_hours; time_bucket | max @@ -1758,34 +1748,34 @@ INSERT INTO temperature values('2020-01-02 01:35:00+01', 5555); INSERT INTO temperature values('2020-01-02 05:05:00+01', 8888); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] -psql:include/cagg_query_common.sql:726: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] -psql:include/cagg_query_common.sql:726: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 +psql:include/cagg_query_common.sql:716: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] +psql:include/cagg_query_common.sql:716: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] +psql:include/cagg_query_common.sql:716: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] -psql:include/cagg_query_common.sql:727: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] -psql:include/cagg_query_common.sql:727: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 +psql:include/cagg_query_common.sql:717: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] +psql:include/cagg_query_common.sql:717: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] +psql:include/cagg_query_common.sql:717: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 RESET client_min_messages; -psql:include/cagg_query_common.sql:728: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:718: LOG: statement: RESET client_min_messages; ALTER MATERIALIZED VIEW cagg_4_hours SET (timescaledb.materialized_only=true); SELECT * FROM cagg_4_hours; time_bucket | max @@ -1981,7 +1971,7 @@ CREATE MATERIALIZED VIEW cagg_1_year SELECT time_bucket('1 year', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:766: NOTICE: refreshing continuous aggregate "cagg_1_year" +psql:include/cagg_query_common.sql:756: NOTICE: refreshing continuous aggregate "cagg_1_year" SELECT * FROM _timescaledb_catalog.continuous_aggs_materialization_invalidation_log ORDER BY 1, 2, 3; materialization_id | lowest_modified_value | greatest_modified_value --------------------+-----------------------+------------------------- @@ -2013,13 +2003,13 @@ CREATE MATERIALIZED VIEW cagg_int AS SELECT time_bucket('10', time), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:783: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:773: NOTICE: refreshing continuous aggregate "cagg_int" CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>5), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:789: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:779: NOTICE: refreshing continuous aggregate "cagg_int_offset" -- Compare bucketing results SELECT time_bucket('10', time), SUM(data) FROM table_int GROUP BY 1 ORDER BY 1; time_bucket | sum @@ -2234,13 +2224,13 @@ SELECT * FROM cagg_int_offset; INSERT INTO table_int VALUES(114, 0); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] -psql:include/cagg_query_common.sql:824: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially -psql:include/cagg_query_common.sql:824: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication -psql:include/cagg_query_common.sql:824: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" +psql:include/cagg_query_common.sql:814: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); +psql:include/cagg_query_common.sql:814: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] +psql:include/cagg_query_common.sql:814: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially +psql:include/cagg_query_common.sql:814: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication +psql:include/cagg_query_common.sql:814: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" RESET client_min_messages; -psql:include/cagg_query_common.sql:825: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:815: LOG: statement: RESET client_min_messages; SELECT * FROM cagg_int_offset; time_bucket | value -------------+------- @@ -2283,45 +2273,45 @@ CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin SELECT time_bucket('1 year', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:835: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" +psql:include/cagg_query_common.sql:825: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin; -psql:include/cagg_query_common.sql:837: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:827: NOTICE: drop cascades to 2 other objects -- Variable due to the used timezone CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2 WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:844: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" +psql:include/cagg_query_common.sql:834: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2; -psql:include/cagg_query_common.sql:846: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:836: NOTICE: drop cascades to 2 other objects -- Variable with offset CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3 WITH (timescaledb.continuous) AS SELECT time_bucket('1 year', time, "offset"=>'5 minutes'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:853: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" +psql:include/cagg_query_common.sql:843: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin3'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin3 | public.time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin3 | time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3; -psql:include/cagg_query_common.sql:855: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:845: NOTICE: drop cascades to 2 other objects --- -- Test with blocking a few broken configurations --- @@ -2334,26 +2324,26 @@ CREATE MATERIALIZED VIEW cagg_1_hour_origin SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:870: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" +psql:include/cagg_query_common.sql:860: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" CREATE MATERIALIZED VIEW cagg_1_week_origin WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, origin=>'2022-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_origin GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:876: ERROR: cannot create continuous aggregate with different bucket origin values +psql:include/cagg_query_common.sql:866: ERROR: cannot create continuous aggregate with different bucket origin values -- Different time offset CREATE MATERIALIZED VIEW cagg_1_hour_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, "offset"=>'30m'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:883: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:873: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" CREATE MATERIALIZED VIEW cagg_1_week_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:889: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:879: ERROR: cannot create continuous aggregate with different bucket offset values -- Cagg with NULL offset on top of cagg with non-NULL offset \set VERBOSITY default CREATE MATERIALIZED VIEW cagg_1_week_null_offset @@ -2361,7 +2351,7 @@ CREATE MATERIALIZED VIEW cagg_1_week_null_offset SELECT time_bucket('1 week', hour_bucket, "offset"=>NULL::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:897: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:887: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_null_offset" [NULL] and "public.cagg_1_hour_offset" [@ 30 mins] should be the same. -- Cagg with non-NULL offset on top of cagg with NULL offset CREATE MATERIALIZED VIEW cagg_1_hour_null_offset @@ -2369,14 +2359,14 @@ CREATE MATERIALIZED VIEW cagg_1_hour_null_offset SELECT time_bucket('1 hour', time, "offset"=>NULL::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:904: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" +psql:include/cagg_query_common.sql:894: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" HINT: Use WITH NO DATA if you do not want to refresh the continuous aggregate on creation. CREATE MATERIALIZED VIEW cagg_1_week_non_null_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_null_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:910: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:900: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_non_null_offset" [@ 35 mins] and "public.cagg_1_hour_null_offset" [NULL] should be the same. \set VERBOSITY terse -- Different integer offset @@ -2385,20 +2375,20 @@ CREATE MATERIALIZED VIEW cagg_int_offset_5 AS SELECT time_bucket('10', time, "offset"=>5) AS time, SUM(data) AS value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:918: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" +psql:include/cagg_query_common.sql:908: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" CREATE MATERIALIZED VIEW cagg_int_offset_10 WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>10) AS time, SUM(value) AS value FROM cagg_int_offset_5 GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:924: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:914: ERROR: cannot create continuous aggregate with different bucket offset values \set ON_ERROR_STOP 1 DROP MATERIALIZED VIEW cagg_1_hour_origin; -psql:include/cagg_query_common.sql:928: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:918: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_1_hour_offset; -psql:include/cagg_query_common.sql:929: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:919: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_int_offset_5; -psql:include/cagg_query_common.sql:930: NOTICE: drop cascades to 3 other objects +psql:include/cagg_query_common.sql:920: NOTICE: drop cascades to 3 other objects --- -- CAGGs on CAGGs tests --- @@ -2407,11 +2397,11 @@ CREATE MATERIALIZED VIEW cagg_1_hour_offset SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:939: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:929: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) CREATE MATERIALIZED VIEW cagg_1_week_offset @@ -2419,11 +2409,11 @@ CREATE MATERIALIZED VIEW cagg_1_week_offset SELECT time_bucket('1 week', hour_bucket, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:946: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" +psql:include/cagg_query_common.sql:936: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_week_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_week_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_week_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) -- Compare output diff --git a/tsl/test/expected/cagg_query_using_merge-17.out b/tsl/test/expected/cagg_query_using_merge-17.out index 71bf6d60a91..c5b3081df31 100644 --- a/tsl/test/expected/cagg_query_using_merge-17.out +++ b/tsl/test/expected/cagg_query_using_merge-17.out @@ -13,6 +13,7 @@ SET timescaledb.enable_merge_on_cagg_refresh TO ON; -- This file and its contents are licensed under the Timescale License. -- Please see the included NOTICE for copyright information and -- LICENSE-TIMESCALE for a copy of the license. +\set TEST_BASE_NAME cagg_query SELECT format('%s/results/%s_results_view.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW", format('%s/results/%s_results_view_hashagg.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW_HASHAGG", @@ -757,7 +758,7 @@ CREATE TABLE temperature_wo_tz ( value float ); SELECT create_hypertable('temperature_wo_tz', 'time'); -psql:include/cagg_query_common.sql:316: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices +psql:include/cagg_query_common.sql:317: WARNING: column type "timestamp without time zone" used for "time" does not follow best practices create_hypertable -------------------------------- (5,public,temperature_wo_tz,t) @@ -789,21 +790,21 @@ CREATE TABLE table_bigint ( data bigint ); SELECT create_hypertable('table_smallint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:345: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" create_hypertable ----------------------------- (7,public,table_smallint,t) (1 row) SELECT create_hypertable('table_int', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:346: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" create_hypertable ------------------------ (8,public,table_int,t) (1 row) SELECT create_hypertable('table_bigint', 'time', chunk_time_interval => 10); -psql:include/cagg_query_common.sql:347: NOTICE: adding not-null constraint to column "time" +psql:include/cagg_query_common.sql:348: NOTICE: adding not-null constraint to column "time" create_hypertable --------------------------- (9,public,table_bigint,t) @@ -835,7 +836,7 @@ INSERT INTO table_int VALUES(1,2); INSERT INTO table_bigint VALUES(1,2); CREATE VIEW caggs_info AS SELECT user_view_schema, user_view_name, bucket_func, bucket_width, bucket_origin, bucket_offset, bucket_timezone, bucket_fixed_width -FROM _timescaledb_catalog.continuous_aggs_bucket_function NATURAL JOIN _timescaledb_catalog.continuous_agg; +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id); --- -- Tests with CAgg creation --- @@ -844,128 +845,128 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:372: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:373: NOTICE: refreshing continuous aggregate "cagg_4_hours" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours | public.time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours | time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours; -psql:include/cagg_query_common.sql:374: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk +psql:include/cagg_query_common.sql:375: NOTICE: drop cascades to table _timescaledb_internal._hyper_10_14_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:380: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:381: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset; -psql:include/cagg_query_common.sql:382: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk +psql:include/cagg_query_common.sql:383: NOTICE: drop cascades to table _timescaledb_internal._hyper_11_15_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:388: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" +psql:include/cagg_query_common.sql:389: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset2 | public.time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset2 | time_bucket(interval,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset2; -psql:include/cagg_query_common.sql:390: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk +psql:include/cagg_query_common.sql:391: NOTICE: drop cascades to table _timescaledb_internal._hyper_12_16_chunk -- Variable buckets (timezone is provided) with offset CREATE MATERIALIZED VIEW cagg_4_hours_offset_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:397: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" +psql:include/cagg_query_common.sql:398: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | | @ 30 mins | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_ts; -psql:include/cagg_query_common.sql:399: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk +psql:include/cagg_query_common.sql:400: NOTICE: drop cascades to table _timescaledb_internal._hyper_13_17_chunk CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:405: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:406: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin; -psql:include/cagg_query_common.sql:407: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk +psql:include/cagg_query_common.sql:408: NOTICE: drop cascades to table _timescaledb_internal._hyper_14_18_chunk -- Using named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:414: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" +psql:include/cagg_query_common.sql:415: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin2 | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin2 | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin2; -psql:include/cagg_query_common.sql:416: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk +psql:include/cagg_query_common.sql:417: NOTICE: drop cascades to table _timescaledb_internal._hyper_15_19_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:423: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" +psql:include/cagg_query_common.sql:424: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts; -psql:include/cagg_query_common.sql:425: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk +psql:include/cagg_query_common.sql:426: NOTICE: drop cascades to table _timescaledb_internal._hyper_16_20_chunk -- Without named parameter CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, 'UTC', '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:432: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" +psql:include/cagg_query_common.sql:433: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Sat Jan 01 01:00:00 2000 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts2; -psql:include/cagg_query_common.sql:434: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk +psql:include/cagg_query_common.sql:435: NOTICE: drop cascades to table _timescaledb_internal._hyper_17_21_chunk -- Timestamp based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:441: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" +psql:include/cagg_query_common.sql:442: NOTICE: refreshing continuous aggregate "cagg_4_hours_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+----------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_wo_tz | public.time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+---------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_wo_tz | time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t (1 row) CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz @@ -973,169 +974,169 @@ CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:448: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" +psql:include/cagg_query_common.sql:449: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz; -psql:include/cagg_query_common.sql:450: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk +psql:include/cagg_query_common.sql:451: NOTICE: drop cascades to table _timescaledb_internal._hyper_19_23_chunk -- Variable buckets (timezone is provided) with origin CREATE MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, origin=>'2000-01-01 01:00:00'::timestamp), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:457: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" +psql:include/cagg_query_common.sql:458: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin_ts_wo_tz2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_origin_ts_wo_tz2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------+--------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_origin_ts_wo_tz2 | public.time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------+-------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_origin_ts_wo_tz2 | time_bucket(interval,timestamp without time zone,timestamp without time zone) | @ 4 hours | Fri Dec 31 17:00:00 1999 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_origin_ts_wo_tz2; -psql:include/cagg_query_common.sql:459: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk +psql:include/cagg_query_common.sql:460: NOTICE: drop cascades to table _timescaledb_internal._hyper_20_24_chunk CREATE MATERIALIZED VIEW cagg_4_hours_offset_wo_tz WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval), max(value) FROM temperature_wo_tz GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:465: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" +psql:include/cagg_query_common.sql:466: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset_wo_tz" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_offset_wo_tz'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+-------------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_offset_wo_tz | public.time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_offset_wo_tz | time_bucket(interval,timestamp without time zone,interval) | @ 4 hours | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_offset_wo_tz; -psql:include/cagg_query_common.sql:467: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk +psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_21_25_chunk DROP MATERIALIZED VIEW cagg_4_hours_wo_tz; -psql:include/cagg_query_common.sql:468: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk +psql:include/cagg_query_common.sql:469: NOTICE: drop cascades to table _timescaledb_internal._hyper_18_22_chunk -- Date based CAggs CREATE MATERIALIZED VIEW cagg_4_hours_date WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:475: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" +psql:include/cagg_query_common.sql:476: NOTICE: refreshing continuous aggregate "cagg_4_hours_date" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------+----------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date | public.time_bucket(interval,pg_catalog.date) | @ 4 days | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date | time_bucket(interval,date) | @ 4 days | | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date; -psql:include/cagg_query_common.sql:477: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk +psql:include/cagg_query_common.sql:478: NOTICE: drop cascades to table _timescaledb_internal._hyper_22_26_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, '2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:483: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" +psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin; -psql:include/cagg_query_common.sql:485: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk +psql:include/cagg_query_common.sql:486: NOTICE: drop cascades to table _timescaledb_internal._hyper_23_27_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2 WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, origin=>'2000-01-01'::date), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:491: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" +psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_origin2 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_origin2; -psql:include/cagg_query_common.sql:493: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk +psql:include/cagg_query_common.sql:494: NOTICE: drop cascades to table _timescaledb_internal._hyper_24_28_chunk CREATE MATERIALIZED VIEW cagg_4_hours_date_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 days', time, "offset"=>'30m'::interval), max(value) FROM temperature_date GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:499: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" +psql:include/cagg_query_common.sql:500: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------------+-------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_4_hours_date_offset | public.time_bucket(interval,pg_catalog.date,interval) | @ 4 days | | @ 30 mins | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_4_hours_date_offset | time_bucket(interval,date,interval) | @ 4 days | | @ 30 mins | | t (1 row) DROP MATERIALIZED VIEW cagg_4_hours_date_offset; -psql:include/cagg_query_common.sql:501: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk +psql:include/cagg_query_common.sql:502: NOTICE: drop cascades to table _timescaledb_internal._hyper_25_29_chunk -- Integer based CAggs CREATE MATERIALIZED VIEW cagg_smallint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:508: NOTICE: refreshing continuous aggregate "cagg_smallint" +psql:include/cagg_query_common.sql:509: NOTICE: refreshing continuous aggregate "cagg_smallint" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+---------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint | public.time_bucket(smallint,smallint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+--------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint | time_bucket(smallint,smallint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint; -psql:include/cagg_query_common.sql:510: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk +psql:include/cagg_query_common.sql:511: NOTICE: drop cascades to table _timescaledb_internal._hyper_26_30_chunk CREATE MATERIALIZED VIEW cagg_smallint_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::smallint), SUM(data) as value FROM table_smallint GROUP BY 1; -psql:include/cagg_query_common.sql:516: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" +psql:include/cagg_query_common.sql:517: NOTICE: refreshing continuous aggregate "cagg_smallint_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_smallint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------------+------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_smallint_offset | public.time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------------+-----------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_smallint_offset | time_bucket(smallint,smallint,smallint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_smallint_offset; -psql:include/cagg_query_common.sql:518: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk +psql:include/cagg_query_common.sql:519: NOTICE: drop cascades to table _timescaledb_internal._hyper_27_31_chunk CREATE MATERIALIZED VIEW cagg_int WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:524: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:525: NOTICE: refreshing continuous aggregate "cagg_int" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int | public.time_bucket(integer,integer) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int | time_bucket(integer,integer) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_int; -psql:include/cagg_query_common.sql:526: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk +psql:include/cagg_query_common.sql:527: NOTICE: drop cascades to table _timescaledb_internal._hyper_28_32_chunk CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time, "offset"=>1::int), SUM(data) as value FROM table_int GROUP BY 1; -psql:include/cagg_query_common.sql:532: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:533: NOTICE: refreshing continuous aggregate "cagg_int_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_int_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-----------------+---------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_int_offset | public.time_bucket(integer,integer,integer) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-----------------+--------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_int_offset | time_bucket(integer,integer,integer) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_int_offset; -psql:include/cagg_query_common.sql:534: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk +psql:include/cagg_query_common.sql:535: NOTICE: drop cascades to table _timescaledb_internal._hyper_29_33_chunk CREATE MATERIALIZED VIEW cagg_bigint WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS SELECT time_bucket('2', time), SUM(data) as value FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+----------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint | public.time_bucket(bigint,bigint) | 2 | | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+----------------+----------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint | time_bucket(bigint,bigint) | 2 | | | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint; @@ -1145,9 +1146,9 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) DROP MATERIALIZED VIEW cagg_bigint_offset; @@ -1158,22 +1159,11 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset2 FROM table_bigint GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+---------------------+------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_bigint_offset2 | public.time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+---------------------+-----------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_bigint_offset2 | time_bucket(bigint,bigint,bigint) | 2 | | 1 | | t (1 row) --- mess with the bucket_func signature to make sure it will raise an exception -SET ROLE :ROLE_CLUSTER_SUPERUSER; -\set ON_ERROR_STOP 0 -BEGIN; -UPDATE _timescaledb_catalog.continuous_aggs_bucket_function SET bucket_func = 'func_does_not_exist()'; --- should error because function does not exist -CALL refresh_continuous_aggregate('cagg_bigint_offset2', NULL, NULL); -psql:include/cagg_query_common.sql:566: ERROR: function "func_does_not_exist()" does not exist -ROLLBACK; -\set ON_ERROR_STOP 1 -SET ROLE :ROLE_DEFAULT_PERM_USER; DROP MATERIALIZED VIEW cagg_bigint_offset2; -- Test invalid bucket definitions \set ON_ERROR_STOP 0 @@ -1183,14 +1173,14 @@ CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:580: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 +psql:include/cagg_query_common.sql:570: ERROR: function time_bucket(unknown, timestamp with time zone, offset => interval, origin => timestamp with time zone) does not exist at character 140 -- Offset and origin at the same time is not allowed (function does exists but invalid parameter combination) CREATE MATERIALIZED VIEW cagg_4_hours_offset_and_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, "offset"=>'30m'::interval, origin=>'2000-01-01 01:00:00 PST'::timestamptz, timezone=>'UTC'), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:587: ERROR: using offset and origin in a time_bucket function at the same time is not supported +psql:include/cagg_query_common.sql:577: ERROR: using offset and origin in a time_bucket function at the same time is not supported \set ON_ERROR_STOP 1 --- -- Tests with CAgg processing @@ -1217,20 +1207,20 @@ CREATE MATERIALIZED VIEW cagg_4_hours SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:613: NOTICE: refreshing continuous aggregate "cagg_4_hours" +psql:include/cagg_query_common.sql:603: NOTICE: refreshing continuous aggregate "cagg_4_hours" CREATE MATERIALIZED VIEW cagg_4_hours_offset WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '30m'::interval), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:619: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" +psql:include/cagg_query_common.sql:609: NOTICE: refreshing continuous aggregate "cagg_4_hours_offset" -- Align origin with first value CREATE MATERIALIZED VIEW cagg_4_hours_origin WITH (timescaledb.continuous, timescaledb.materialized_only = false) AS SELECT time_bucket('4 hour', time, '2000-01-01 01:00:00 PST'::timestamptz), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:626: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" +psql:include/cagg_query_common.sql:616: NOTICE: refreshing continuous aggregate "cagg_4_hours_origin" -- Query the CAggs and check that all buckets are materialized SELECT time_bucket('4 hour', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; time_bucket | max @@ -1539,23 +1529,23 @@ SELECT * FROM cagg_4_hours_origin; -- Update materialized data SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:683: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] -psql:include/cagg_query_common.sql:683: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:673: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:673: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Thu Jan 02 00:00:00 2020 PST, Thu Jan 02 12:00:00 2020 PST ] +psql:include/cagg_query_common.sql:673: LOG: inserted 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:684: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:684: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] -psql:include/cagg_query_common.sql:684: LOG: merged 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:684: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:674: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:674: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Wed Jan 01 20:30:00 2020 PST, Thu Jan 02 12:30:00 2020 PST ] +psql:include/cagg_query_common.sql:674: LOG: merged 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:674: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_34" CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:685: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 -psql:include/cagg_query_common.sql:685: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] -psql:include/cagg_query_common.sql:685: LOG: merged 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:685: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:675: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577995200000000 +psql:include/cagg_query_common.sql:675: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Wed Jan 01 21:00:00 2020 PST, Thu Jan 02 13:00:00 2020 PST ] +psql:include/cagg_query_common.sql:675: LOG: merged 3 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:675: LOG: deleted 0 row(s) from materialization table "_timescaledb_internal._materialized_hypertable_35" RESET client_min_messages; -psql:include/cagg_query_common.sql:686: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:676: LOG: statement: RESET client_min_messages; -- Query the CAggs and check that all buckets are materialized SELECT * FROM cagg_4_hours; time_bucket | max @@ -1758,34 +1748,34 @@ INSERT INTO temperature values('2020-01-02 01:35:00+01', 5555); INSERT INTO temperature values('2020-01-02 05:05:00+01', 8888); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 -psql:include/cagg_query_common.sql:725: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] -psql:include/cagg_query_common.sql:725: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" -psql:include/cagg_query_common.sql:725: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours', NULL, NULL); +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Sat Jan 01 00:00:00 2000 PST, Sun Jan 02 00:00:00 2000 PST ] +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 946800000000000 +psql:include/cagg_query_common.sql:715: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours" in window [ Wed Jan 01 00:00:00 2020 PST, Thu Jan 02 00:00:00 2020 PST ] +psql:include/cagg_query_common.sql:715: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_33" +psql:include/cagg_query_common.sql:715: DEBUG: hypertable 33 existing watermark >= new watermark 1577995200000000 1577952000000000 CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] -psql:include/cagg_query_common.sql:726: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 -psql:include/cagg_query_common.sql:726: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] -psql:include/cagg_query_common.sql:726: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" -psql:include/cagg_query_common.sql:726: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 +psql:include/cagg_query_common.sql:716: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_offset', NULL, NULL); +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Fri Dec 31 20:30:00 1999 PST, Sun Jan 02 00:30:00 2000 PST ] +psql:include/cagg_query_common.sql:716: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 946801800000000 +psql:include/cagg_query_common.sql:716: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_offset" in window [ Tue Dec 31 20:30:00 2019 PST, Thu Jan 02 00:30:00 2020 PST ] +psql:include/cagg_query_common.sql:716: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_34" +psql:include/cagg_query_common.sql:716: DEBUG: hypertable 34 existing watermark >= new watermark 1577997000000000 1577953800000000 CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] -psql:include/cagg_query_common.sql:727: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 -psql:include/cagg_query_common.sql:727: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] -psql:include/cagg_query_common.sql:727: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" -psql:include/cagg_query_common.sql:727: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 +psql:include/cagg_query_common.sql:717: LOG: statement: CALL refresh_continuous_aggregate('cagg_4_hours_origin', NULL, NULL); +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 4 existing watermark >= new invalidation threshold 1577995200000000 1577952000000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Fri Dec 31 21:00:00 1999 PST, Sun Jan 02 01:00:00 2000 PST ] +psql:include/cagg_query_common.sql:717: LOG: inserted 6 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 946803600000000 +psql:include/cagg_query_common.sql:717: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_4_hours_origin" in window [ Tue Dec 31 21:00:00 2019 PST, Thu Jan 02 01:00:00 2020 PST ] +psql:include/cagg_query_common.sql:717: LOG: inserted 7 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_35" +psql:include/cagg_query_common.sql:717: DEBUG: hypertable 35 existing watermark >= new watermark 1577998800000000 1577955600000000 RESET client_min_messages; -psql:include/cagg_query_common.sql:728: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:718: LOG: statement: RESET client_min_messages; ALTER MATERIALIZED VIEW cagg_4_hours SET (timescaledb.materialized_only=true); SELECT * FROM cagg_4_hours; time_bucket | max @@ -1981,7 +1971,7 @@ CREATE MATERIALIZED VIEW cagg_1_year SELECT time_bucket('1 year', time), max(value) FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:766: NOTICE: refreshing continuous aggregate "cagg_1_year" +psql:include/cagg_query_common.sql:756: NOTICE: refreshing continuous aggregate "cagg_1_year" SELECT * FROM _timescaledb_catalog.continuous_aggs_materialization_invalidation_log ORDER BY 1, 2, 3; materialization_id | lowest_modified_value | greatest_modified_value --------------------+-----------------------+------------------------- @@ -2013,13 +2003,13 @@ CREATE MATERIALIZED VIEW cagg_int AS SELECT time_bucket('10', time), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:783: NOTICE: refreshing continuous aggregate "cagg_int" +psql:include/cagg_query_common.sql:773: NOTICE: refreshing continuous aggregate "cagg_int" CREATE MATERIALIZED VIEW cagg_int_offset WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>5), SUM(data) as value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:789: NOTICE: refreshing continuous aggregate "cagg_int_offset" +psql:include/cagg_query_common.sql:779: NOTICE: refreshing continuous aggregate "cagg_int_offset" -- Compare bucketing results SELECT time_bucket('10', time), SUM(data) FROM table_int GROUP BY 1 ORDER BY 1; time_bucket | sum @@ -2234,13 +2224,13 @@ SELECT * FROM cagg_int_offset; INSERT INTO table_int VALUES(114, 0); SET client_min_messages TO DEBUG1; CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); -psql:include/cagg_query_common.sql:824: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] -psql:include/cagg_query_common.sql:824: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially -psql:include/cagg_query_common.sql:824: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication -psql:include/cagg_query_common.sql:824: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" +psql:include/cagg_query_common.sql:814: LOG: statement: CALL refresh_continuous_aggregate('cagg_int_offset', 110, 130); +psql:include/cagg_query_common.sql:814: DEBUG: continuous aggregate refresh (individual invalidation) on "cagg_int_offset" in window [ 105, 135 ] +psql:include/cagg_query_common.sql:814: DEBUG: building index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" on table "_hyper_38_67_chunk" serially +psql:include/cagg_query_common.sql:814: DEBUG: index "_hyper_38_67_chunk__materialized_hypertable_38_time_bucket_idx" can safely use deduplication +psql:include/cagg_query_common.sql:814: LOG: inserted 1 row(s) into materialization table "_timescaledb_internal._materialized_hypertable_38" RESET client_min_messages; -psql:include/cagg_query_common.sql:825: LOG: statement: RESET client_min_messages; +psql:include/cagg_query_common.sql:815: LOG: statement: RESET client_min_messages; SELECT * FROM cagg_int_offset; time_bucket | value -------------+------- @@ -2283,45 +2273,45 @@ CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin SELECT time_bucket('1 year', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:835: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" +psql:include/cagg_query_common.sql:825: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 year | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin; -psql:include/cagg_query_common.sql:837: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:827: NOTICE: drop cascades to 2 other objects -- Variable due to the used timezone CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2 WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, origin=>'2000-01-01 01:05:00 UTC'::timestamptz, timezone=>'UTC') AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:844: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" +psql:include/cagg_query_common.sql:834: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin2" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin2'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+---------------------------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin2 | public.time_bucket(interval,timestamp with time zone,pg_catalog.text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin2 | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 1 hour | Fri Dec 31 17:05:00 1999 PST | | UTC | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin2; -psql:include/cagg_query_common.sql:846: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:836: NOTICE: drop cascades to 2 other objects -- Variable with offset CREATE MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3 WITH (timescaledb.continuous) AS SELECT time_bucket('1 year', time, "offset"=>'5 minutes'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:853: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" +psql:include/cagg_query_common.sql:843: NOTICE: refreshing continuous aggregate "cagg_1_hour_variable_bucket_fixed_origin3" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_variable_bucket_fixed_origin3'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+-------------------------------------------+----------------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- - public | cagg_1_hour_variable_bucket_fixed_origin3 | public.time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+-------------------------------------------+---------------------------------------------------------+--------------+---------------+---------------+-----------------+-------------------- + public | cagg_1_hour_variable_bucket_fixed_origin3 | time_bucket(interval,timestamp with time zone,interval) | @ 1 year | | @ 5 mins | | f (1 row) DROP MATERIALIZED VIEW cagg_1_hour_variable_bucket_fixed_origin3; -psql:include/cagg_query_common.sql:855: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:845: NOTICE: drop cascades to 2 other objects --- -- Test with blocking a few broken configurations --- @@ -2334,26 +2324,26 @@ CREATE MATERIALIZED VIEW cagg_1_hour_origin SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:870: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" +psql:include/cagg_query_common.sql:860: NOTICE: refreshing continuous aggregate "cagg_1_hour_origin" CREATE MATERIALIZED VIEW cagg_1_week_origin WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, origin=>'2022-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_origin GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:876: ERROR: cannot create continuous aggregate with different bucket origin values +psql:include/cagg_query_common.sql:866: ERROR: cannot create continuous aggregate with different bucket origin values -- Different time offset CREATE MATERIALIZED VIEW cagg_1_hour_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time, "offset"=>'30m'::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:883: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:873: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" CREATE MATERIALIZED VIEW cagg_1_week_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:889: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:879: ERROR: cannot create continuous aggregate with different bucket offset values -- Cagg with NULL offset on top of cagg with non-NULL offset \set VERBOSITY default CREATE MATERIALIZED VIEW cagg_1_week_null_offset @@ -2361,7 +2351,7 @@ CREATE MATERIALIZED VIEW cagg_1_week_null_offset SELECT time_bucket('1 week', hour_bucket, "offset"=>NULL::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:897: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:887: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_null_offset" [NULL] and "public.cagg_1_hour_offset" [@ 30 mins] should be the same. -- Cagg with non-NULL offset on top of cagg with NULL offset CREATE MATERIALIZED VIEW cagg_1_hour_null_offset @@ -2369,14 +2359,14 @@ CREATE MATERIALIZED VIEW cagg_1_hour_null_offset SELECT time_bucket('1 hour', time, "offset"=>NULL::interval) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:904: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" +psql:include/cagg_query_common.sql:894: NOTICE: refreshing continuous aggregate "cagg_1_hour_null_offset" HINT: Use WITH NO DATA if you do not want to refresh the continuous aggregate on creation. CREATE MATERIALIZED VIEW cagg_1_week_non_null_offset WITH (timescaledb.continuous) AS SELECT time_bucket('1 week', hour_bucket, "offset"=>'35m'::interval) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_null_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:910: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:900: ERROR: cannot create continuous aggregate with different bucket offset values DETAIL: Time origin of "public.cagg_1_week_non_null_offset" [@ 35 mins] and "public.cagg_1_hour_null_offset" [NULL] should be the same. \set VERBOSITY terse -- Different integer offset @@ -2385,20 +2375,20 @@ CREATE MATERIALIZED VIEW cagg_int_offset_5 AS SELECT time_bucket('10', time, "offset"=>5) AS time, SUM(data) AS value FROM table_int GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:918: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" +psql:include/cagg_query_common.sql:908: NOTICE: refreshing continuous aggregate "cagg_int_offset_5" CREATE MATERIALIZED VIEW cagg_int_offset_10 WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS SELECT time_bucket('10', time, "offset"=>10) AS time, SUM(value) AS value FROM cagg_int_offset_5 GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:924: ERROR: cannot create continuous aggregate with different bucket offset values +psql:include/cagg_query_common.sql:914: ERROR: cannot create continuous aggregate with different bucket offset values \set ON_ERROR_STOP 1 DROP MATERIALIZED VIEW cagg_1_hour_origin; -psql:include/cagg_query_common.sql:928: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:918: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_1_hour_offset; -psql:include/cagg_query_common.sql:929: NOTICE: drop cascades to 2 other objects +psql:include/cagg_query_common.sql:919: NOTICE: drop cascades to 2 other objects DROP MATERIALIZED VIEW cagg_int_offset_5; -psql:include/cagg_query_common.sql:930: NOTICE: drop cascades to 3 other objects +psql:include/cagg_query_common.sql:920: NOTICE: drop cascades to 3 other objects --- -- CAGGs on CAGGs tests --- @@ -2407,11 +2397,11 @@ CREATE MATERIALIZED VIEW cagg_1_hour_offset SELECT time_bucket('1 hour', time, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS hour_bucket, max(value) AS max_value FROM temperature GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:939: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" +psql:include/cagg_query_common.sql:929: NOTICE: refreshing continuous aggregate "cagg_1_hour_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_hour_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_hour_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_hour_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 1 hour | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) CREATE MATERIALIZED VIEW cagg_1_week_offset @@ -2419,11 +2409,11 @@ CREATE MATERIALIZED VIEW cagg_1_week_offset SELECT time_bucket('1 week', hour_bucket, origin=>'2000-01-02 01:00:00 PST'::timestamptz) AS week_bucket, max(max_value) AS max_value FROM cagg_1_hour_offset GROUP BY 1 ORDER BY 1; -psql:include/cagg_query_common.sql:946: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" +psql:include/cagg_query_common.sql:936: NOTICE: refreshing continuous aggregate "cagg_1_week_offset" SELECT * FROM caggs_info WHERE user_view_name = 'cagg_1_week_offset'; - user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width -------------------+--------------------+--------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- - public | cagg_1_week_offset | public.time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t + user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width +------------------+--------------------+-------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- + public | cagg_1_week_offset | time_bucket(interval,timestamp with time zone,timestamp with time zone) | @ 7 days | Sun Jan 02 01:00:00 2000 PST | | | t (1 row) -- Compare output diff --git a/tsl/test/expected/cagg_utils.out b/tsl/test/expected/cagg_utils.out index 8ac4bf55243..9eee9ca0bf7 100644 --- a/tsl/test/expected/cagg_utils.out +++ b/tsl/test/expected/cagg_utils.out @@ -378,10 +378,10 @@ ORDER BY user_view_name; -----------------------------+---------------------------------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+-------------------- integer_ht_cagg | time_bucket(integer,integer) | 1 | | | | t integer_ht_cagg_offset | time_bucket(integer,integer,integer) | 1 | | 10 | | t - temperature_4h | time_bucket(interval,timestamp without time zone) | @ 4 hours | Fri Dec 31 16:00:00 1999 PST | | | t - temperature_tz_4h | time_bucket(interval,timestamp with time zone) | @ 4 hours | Fri Dec 31 16:00:00 1999 PST | | | t - temperature_tz_4h_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Fri Dec 31 16:00:00 1999 PST | | Europe/Berlin | f - temperature_tz_4h_ts_offset | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Fri Dec 31 16:00:00 1999 PST | @ 1 hour | Europe/Berlin | f + temperature_4h | time_bucket(interval,timestamp without time zone) | @ 4 hours | | | | t + temperature_tz_4h | time_bucket(interval,timestamp with time zone) | @ 4 hours | | | | t + temperature_tz_4h_ts | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | | | Europe/Berlin | f + temperature_tz_4h_ts_offset | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | | @ 1 hour | Europe/Berlin | f temperature_tz_4h_ts_origin | time_bucket(interval,timestamp with time zone,text,timestamp with time zone,interval) | @ 4 hours | Mon Jan 01 00:00:00 2001 PST | | Europe/Berlin | f (7 rows) diff --git a/tsl/test/sql/CMakeLists.txt b/tsl/test/sql/CMakeLists.txt index af050f455cf..2b3a007d7a2 100644 --- a/tsl/test/sql/CMakeLists.txt +++ b/tsl/test/sql/CMakeLists.txt @@ -168,9 +168,12 @@ if((${PG_VERSION_MAJOR} GREATER_EQUAL "15")) merge_compress.sql) endif() +if((${PG_VERSION_MAJOR} GREATER_EQUAL "15")) + list(APPEND TEST_TEMPLATES cagg_query_using_merge.sql.in) +endif() + if((${PG_VERSION_MAJOR} GREATER_EQUAL "16")) list(APPEND TEST_FILES cagg_planning.sql hypercore_parallel.sql) - list(APPEND TEST_TEMPLATES cagg_query_using_merge.sql.in) endif() if((${PG_VERSION_MAJOR} GREATER_EQUAL "17")) diff --git a/tsl/test/sql/cagg_bgw.sql.in b/tsl/test/sql/cagg_bgw.sql.in index 4d1a0a34b74..4391eb2b3e0 100644 --- a/tsl/test/sql/cagg_bgw.sql.in +++ b/tsl/test/sql/cagg_bgw.sql.in @@ -95,7 +95,7 @@ SELECT id as raw_table_id FROM _timescaledb_catalog.hypertable WHERE table_name= -- min distance from end should be 1 SELECT mat_hypertable_id, user_view_schema, user_view_name FROM _timescaledb_catalog.continuous_agg; -SELECT mat_hypertable_id, bucket_width FROM _timescaledb_catalog.continuous_aggs_bucket_function; +SELECT mat_hypertable_id, bucket_width FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id); SELECT mat_hypertable_id FROM _timescaledb_catalog.continuous_agg \gset SELECT id AS job_id FROM _timescaledb_config.bgw_job where hypertable_id=:mat_hypertable_id \gset diff --git a/tsl/test/sql/exp_cagg_monthly.sql b/tsl/test/sql/exp_cagg_monthly.sql index ddfcb25d325..13774955fe7 100644 --- a/tsl/test/sql/exp_cagg_monthly.sql +++ b/tsl/test/sql/exp_cagg_monthly.sql @@ -76,8 +76,8 @@ WHERE user_view_name = 'conditions_summary' \gset \pset null -SELECT * -FROM _timescaledb_catalog.continuous_aggs_bucket_function +SELECT mat_hypertable_id, bf.* +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id) AS bf WHERE mat_hypertable_id = :cagg_id; \pset null "" @@ -103,20 +103,6 @@ SELECT city, to_char(bucket, 'YYYY-MM-DD') AS month, min, max FROM conditions_summary ORDER by month, city; --- Special check for "invalid or missing information about the bucketing --- function" code path -\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER -CREATE TEMPORARY TABLE restore_table ( LIKE _timescaledb_catalog.continuous_aggs_bucket_function ); -INSERT INTO restore_table SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function; -DELETE FROM _timescaledb_catalog.continuous_aggs_bucket_function; -\set ON_ERROR_STOP 0 --- should fail with "invalid or missing information..." -CALL refresh_continuous_aggregate('conditions_summary', '2021-06-01', '2021-07-01'); -\set ON_ERROR_STOP 1 -INSERT INTO _timescaledb_catalog.continuous_aggs_bucket_function SELECT * FROM restore_table; -DROP TABLE restore_table; --- should execute successfully -CALL refresh_continuous_aggregate('conditions_summary', '2021-06-01', '2021-07-01'); SET ROLE :ROLE_DEFAULT_PERM_USER; -- Check the invalidation threshold @@ -166,7 +152,8 @@ DROP MATERIALIZED VIEW conditions_summary; SELECT * FROM _timescaledb_catalog.continuous_agg WHERE mat_hypertable_id = :cagg_id; -SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function +SELECT mat_hypertable_id, bf.* +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id) AS bf WHERE mat_hypertable_id = :cagg_id; -- Re-create cagg, this time WITH DATA diff --git a/tsl/test/sql/exp_cagg_next_gen.sql b/tsl/test/sql/exp_cagg_next_gen.sql index 6aec2b6c784..d0cb03a770f 100644 --- a/tsl/test/sql/exp_cagg_next_gen.sql +++ b/tsl/test/sql/exp_cagg_next_gen.sql @@ -160,8 +160,9 @@ FROM conditions GROUP BY city, bucket WITH NO DATA; -SELECT bucket_func, bucket_width, bucket_origin, bucket_timezone, bucket_fixed_width -FROM _timescaledb_catalog.continuous_aggs_bucket_function ORDER BY 1; +SELECT bf.* +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id) AS bf +ORDER BY 1; -- Try to toggle realtime feature on existing CAgg using timescaledb_experimental.time_bucket_ng ALTER MATERIALIZED VIEW conditions_summary_monthly SET (timescaledb.materialized_only=false); diff --git a/tsl/test/sql/exp_cagg_origin.sql b/tsl/test/sql/exp_cagg_origin.sql index 7641da0d8af..f66377ba5e2 100644 --- a/tsl/test/sql/exp_cagg_origin.sql +++ b/tsl/test/sql/exp_cagg_origin.sql @@ -526,9 +526,9 @@ SELECT mat_hypertable_id AS cagg_id WHERE user_view_name = 'conditions_summary_timestamptz' \gset -SELECT bucket_func, bucket_width, bucket_origin, bucket_timezone, bucket_fixed_width - FROM _timescaledb_catalog.continuous_aggs_bucket_function - WHERE mat_hypertable_id = :cagg_id; +SELECT bf.* +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id) AS bf +WHERE mat_hypertable_id = :cagg_id; SELECT city, to_char(bucket at time zone 'MSK', 'YYYY-MM-DD HH24:MI:SS') AS b, min, max FROM conditions_summary_timestamptz diff --git a/tsl/test/sql/exp_cagg_timezone.sql b/tsl/test/sql/exp_cagg_timezone.sql index 9a93182562f..8c03e6c8949 100644 --- a/tsl/test/sql/exp_cagg_timezone.sql +++ b/tsl/test/sql/exp_cagg_timezone.sql @@ -126,8 +126,8 @@ WHERE user_view_name = 'conditions_summary_tz' \gset -- Make sure the timezone is saved in the catalog table -SELECT bucket_func, bucket_width, bucket_origin, bucket_timezone, bucket_fixed_width -FROM _timescaledb_catalog.continuous_aggs_bucket_function +SELECT bf.* +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id) AS bf WHERE mat_hypertable_id = :cagg_id_tz; -- Make sure that buckets with specified timezone are always treated as @@ -153,8 +153,8 @@ WHERE user_view_name = 'conditions_summary_1w' \gset -- Make sure the timezone is saved in the catalog table -SELECT bucket_func, bucket_width, bucket_origin, bucket_timezone, bucket_fixed_width -FROM _timescaledb_catalog.continuous_aggs_bucket_function +SELECT bf.* +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id) AS bf WHERE mat_hypertable_id = :cagg_id_1w; -- Check the invalidation threshold is -infinity diff --git a/tsl/test/sql/include/cagg_query_common.sql b/tsl/test/sql/include/cagg_query_common.sql index c1bcb3b9da4..e16da6ffec2 100644 --- a/tsl/test/sql/include/cagg_query_common.sql +++ b/tsl/test/sql/include/cagg_query_common.sql @@ -2,6 +2,7 @@ -- Please see the included NOTICE for copyright information and -- LICENSE-TIMESCALE for a copy of the license. +\set TEST_BASE_NAME cagg_query SELECT format('%s/results/%s_results_view.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW", format('%s/results/%s_results_view_hashagg.out', :'TEST_OUTPUT_DIR', :'TEST_BASE_NAME') as "TEST_RESULTS_VIEW_HASHAGG", @@ -360,7 +361,7 @@ INSERT INTO table_bigint VALUES(1,2); CREATE VIEW caggs_info AS SELECT user_view_schema, user_view_name, bucket_func, bucket_width, bucket_origin, bucket_offset, bucket_timezone, bucket_fixed_width -FROM _timescaledb_catalog.continuous_aggs_bucket_function NATURAL JOIN _timescaledb_catalog.continuous_agg; +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id); --- -- Tests with CAgg creation @@ -557,17 +558,6 @@ CREATE MATERIALIZED VIEW cagg_bigint_offset2 GROUP BY 1 WITH NO DATA; SELECT * FROM caggs_info WHERE user_view_name = 'cagg_bigint_offset2'; --- mess with the bucket_func signature to make sure it will raise an exception -SET ROLE :ROLE_CLUSTER_SUPERUSER; -\set ON_ERROR_STOP 0 -BEGIN; -UPDATE _timescaledb_catalog.continuous_aggs_bucket_function SET bucket_func = 'func_does_not_exist()'; --- should error because function does not exist -CALL refresh_continuous_aggregate('cagg_bigint_offset2', NULL, NULL); -ROLLBACK; -\set ON_ERROR_STOP 1 -SET ROLE :ROLE_DEFAULT_PERM_USER; - DROP MATERIALIZED VIEW cagg_bigint_offset2; -- Test invalid bucket definitions diff --git a/tsl/test/sql/include/cagg_run_timebucket_migration.sql b/tsl/test/sql/include/cagg_run_timebucket_migration.sql index 8d166adf8d4..fcab342deda 100644 --- a/tsl/test/sql/include/cagg_run_timebucket_migration.sql +++ b/tsl/test/sql/include/cagg_run_timebucket_migration.sql @@ -8,14 +8,20 @@ SELECT mat_hypertable_id, FROM _timescaledb_catalog.continuous_agg where user_view_name = :'CAGG_NAME' \gset -SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; +SELECT mat_hypertable_id, bf.* +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id) AS bf +WHERE mat_hypertable_id = :mat_hypertable_id; + SELECT pg_get_viewdef(:'partial_view', true); SELECT pg_get_viewdef(:'direct_view', true); SELECT pg_get_viewdef(:'CAGG_NAME', true); CALL _timescaledb_functions.cagg_migrate_to_time_bucket(:'CAGG_NAME'); -SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function WHERE mat_hypertable_id = :mat_hypertable_id; +SELECT mat_hypertable_id, bf.* +FROM _timescaledb_catalog.continuous_agg, LATERAL _timescaledb_functions.cagg_get_bucket_function_info(mat_hypertable_id) AS bf +WHERE mat_hypertable_id = :mat_hypertable_id; + SELECT pg_get_viewdef(:'partial_view', true); SELECT pg_get_viewdef(:'direct_view', true); SELECT pg_get_viewdef(:'CAGG_NAME', true); diff --git a/tsl/test/sql/include/data/cagg_migrate_integer.sql.gz b/tsl/test/sql/include/data/cagg_migrate_integer.sql.gz index 4a67fae9f5d..3a04dba4a6e 100644 Binary files a/tsl/test/sql/include/data/cagg_migrate_integer.sql.gz and b/tsl/test/sql/include/data/cagg_migrate_integer.sql.gz differ diff --git a/tsl/test/sql/include/data/cagg_migrate_timestamp.sql.gz b/tsl/test/sql/include/data/cagg_migrate_timestamp.sql.gz index bb3cf45b41c..227d3405382 100644 Binary files a/tsl/test/sql/include/data/cagg_migrate_timestamp.sql.gz and b/tsl/test/sql/include/data/cagg_migrate_timestamp.sql.gz differ diff --git a/tsl/test/sql/include/data/cagg_migrate_timestamptz.sql.gz b/tsl/test/sql/include/data/cagg_migrate_timestamptz.sql.gz index 32744f15b4f..986ae0384bb 100644 Binary files a/tsl/test/sql/include/data/cagg_migrate_timestamptz.sql.gz and b/tsl/test/sql/include/data/cagg_migrate_timestamptz.sql.gz differ