diff --git a/.unreleased/feature_6382 b/.unreleased/feature_6382 index e7f572fa04f..4b1e499f10b 100644 --- a/.unreleased/feature_6382 +++ b/.unreleased/feature_6382 @@ -1 +1 @@ -Implements: #6382 Support for time_bucket with origin and offset in CAggs +Implements: #6382 Support for time_bucket with origin and offset in CAggs diff --git a/sql/pre_install/tables.sql b/sql/pre_install/tables.sql index d0f20b434c1..7f4cdfb9869 100644 --- a/sql/pre_install/tables.sql +++ b/sql/pre_install/tables.sql @@ -311,7 +311,6 @@ CREATE TABLE _timescaledb_catalog.continuous_agg ( user_view_name name NOT NULL, partial_view_schema name NOT NULL, partial_view_name name NOT NULL, - bucket_width bigint NOT NULL, direct_view_schema name NOT NULL, direct_view_name name NOT NULL, materialized_only bool NOT NULL DEFAULT FALSE, diff --git a/src/ts_catalog/continuous_agg.c b/src/ts_catalog/continuous_agg.c index a1060bae0c5..45ef1b89f4d 100644 --- a/src/ts_catalog/continuous_agg.c +++ b/src/ts_catalog/continuous_agg.c @@ -555,8 +555,11 @@ continuous_agg_init(ContinuousAgg *cagg, const Form_continuous_agg fd) Assert(NULL != cagg_ht); time_dim = hyperspace_get_open_dimension(cagg_ht->space, 0); Assert(NULL != time_dim); - cagg->partition_type = ts_dimension_get_partition_type(time_dim); + cagg->relid = get_relname_relid(NameStr(fd->user_view_name), nspid); + memcpy(&cagg->data, fd, sizeof(cagg->data)); + + Assert(OidIsValid(cagg->relid)); Assert(OidIsValid(cagg->partition_type)); cagg->bucket_function = palloc0(sizeof(ContinuousAggsBucketFunction)); diff --git a/src/ts_catalog/continuous_agg.h b/src/ts_catalog/continuous_agg.h index 178ce49e6b7..07be87887be 100644 --- a/src/ts_catalog/continuous_agg.h +++ b/src/ts_catalog/continuous_agg.h @@ -40,8 +40,6 @@ SetUserIdAndSecContext(saved_uid, saved_secctx); \ } while (0); -#define CAGG_BUCKET_OFFSET_UNDEFINED 0 - typedef enum ContinuousAggViewOption { ContinuousEnabled = 0, diff --git a/tsl/src/continuous_aggs/common.c b/tsl/src/continuous_aggs/common.c index 9271cd942d1..9371aa50e63 100644 --- a/tsl/src/continuous_aggs/common.c +++ b/tsl/src/continuous_aggs/common.c @@ -6,6 +6,9 @@ #include "common.h" +#include +#include + static Const *check_time_bucket_argument(Node *arg, char *position); static void caggtimebucketinfo_init(CAggTimebucketInfo *src, int32 hypertable_id, Oid hypertable_oid, AttrNumber hypertable_partition_colno, @@ -60,11 +63,17 @@ caggtimebucketinfo_init(CAggTimebucketInfo *src, int32 hypertable_id, Oid hypert src->htpartcolno = hypertable_partition_colno; src->htpartcoltype = hypertable_partition_coltype; src->htpartcol_interval_len = hypertable_partition_col_interval; - src->bucket_width = 0; /* invalid value */ - src->bucket_width_type = InvalidOid; /* invalid oid */ - src->interval = NULL; /* not specified by default */ - src->timezone = NULL; /* not specified by default */ - TIMESTAMP_NOBEGIN(src->origin); /* origin is not specified by default */ + src->bucket_width_type = InvalidOid; /* invalid oid */ + + /* Time based buckets */ + src->bucket_time_width = NULL; /* not specified by default */ + src->bucket_time_timezone = NULL; /* not specified by default */ + src->bucket_time_offset = NULL; /* not specified by default */ + TIMESTAMP_NOBEGIN(src->bucket_time_origin); /* origin is not specified by default */ + + /* Integer based buckets */ + src->bucket_integer_width = 0; /* invalid value */ + src->bucket_integer_offset = 0; /* invalid value */ } /* @@ -160,25 +169,24 @@ process_additional_timebucket_parameter(CAggTimebucketInfo *tbinfo, Const *arg) errmsg("invalid timezone name \"%s\"", tz_name))); } - tbinfo->timezone = tz_name; - tbinfo->bucket_width = BUCKET_WIDTH_VARIABLE; + tbinfo->bucket_time_timezone = tz_name; break; case INTERVALOID: /* Bucket offset as interval */ - tbinfo->bucket_offset = DatumGetIntervalP(arg->constvalue); + tbinfo->bucket_time_offset = DatumGetIntervalP(arg->constvalue); break; case DATEOID: /* Bucket origin as Date */ - tbinfo->bucket_origin = + tbinfo->bucket_time_origin = date2timestamptz_opt_overflow(DatumGetDateADT(arg->constvalue), NULL); break; case TIMESTAMPOID: /* Bucket origin as Timestamp */ - tbinfo->bucket_origin = DatumGetTimestamp(arg->constvalue); + tbinfo->bucket_time_origin = DatumGetTimestamp(arg->constvalue); break; case TIMESTAMPTZOID: /* Bucket origin as TimestampTZ */ - tbinfo->bucket_origin = DatumGetTimestampTz(arg->constvalue); + tbinfo->bucket_time_origin = DatumGetTimestampTz(arg->constvalue); break; default: break; diff --git a/tsl/src/continuous_aggs/common.h b/tsl/src/continuous_aggs/common.h index a12a3d35461..7c46f2b5f4c 100644 --- a/tsl/src/continuous_aggs/common.h +++ b/tsl/src/continuous_aggs/common.h @@ -26,9 +26,7 @@ #include #include #include -#include #include -#include #include #include "errors.h" @@ -70,13 +68,8 @@ typedef struct CAggTimebucketInfo Oid htoid; /* hypertable oid */ AttrNumber htpartcolno; /* primary partitioning column of raw hypertable */ /* This should also be the column used by time_bucket */ - Oid htpartcoltype; - int64 htpartcol_interval_len; /* interval length setting for primary partitioning column */ - int64 bucket_width; /* bucket_width of time_bucket, stores BUCKET_WIDTH_VARIABLE for - variable-sized buckets */ - Oid bucket_width_type; /* type of bucket_width */ - Interval *interval; /* stores the interval, NULL if not specified */ - const char *timezone; /* the name of the timezone, NULL if not specified */ + Oid htpartcoltype; /* The collation type */ + int64 htpartcol_interval_len; /* interval length setting for primary partitioning column */ /* General bucket information */ FuncExpr *bucket_func; /* function call expr of the bucketing function */ diff --git a/tsl/src/continuous_aggs/create.c b/tsl/src/continuous_aggs/create.c index f614b9701df..e2a2cbbdcff 100644 --- a/tsl/src/continuous_aggs/create.c +++ b/tsl/src/continuous_aggs/create.c @@ -78,11 +78,9 @@ static void create_cagg_catalog_entry(int32 matht_id, int32 rawht_id, const char *user_schema, const char *user_view, const char *partial_schema, - const char *partial_view, int64 bucket_width, - Interval *bucket_offset, TimestampTz bucket_origin, - bool materialized_only, const char *direct_schema, - const char *direct_view, const bool finalized, - const int32 parent_mat_hypertable_id); + 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, @@ -127,8 +125,7 @@ static Query *mattablecolumninfo_get_partial_select_query(MatTableColumnInfo *ma static void create_cagg_catalog_entry(int32 matht_id, int32 rawht_id, const char *user_schema, const char *user_view, const char *partial_schema, - const char *partial_view, int64 bucket_width, Interval *bucket_offset, - TimestampTz bucket_origin, bool materialized_only, + const char *partial_view, bool materialized_only, const char *direct_schema, const char *direct_view, const bool finalized, const int32 parent_mat_hypertable_id) { @@ -169,7 +166,6 @@ create_cagg_catalog_entry(int32 matht_id, int32 rawht_id, const char *user_schem NameGetDatum(&partial_schnm); values[AttrNumberGetAttrOffset(Anum_continuous_agg_partial_view_name)] = NameGetDatum(&partial_viewnm); - values[AttrNumberGetAttrOffset(Anum_continuous_agg_bucket_width)] = Int64GetDatum(bucket_width); values[AttrNumberGetAttrOffset(Anum_continuous_agg_direct_view_schema)] = NameGetDatum(&direct_schnm); values[AttrNumberGetAttrOffset(Anum_continuous_agg_direct_view_name)] = @@ -816,9 +812,6 @@ cagg_create(const CreateTableAsStmt *create_stmt, ViewStmt *stmt, Query *panquer stmt->view->relname, part_rel->schemaname, part_rel->relname, - bucket_info->bucket_width, - bucket_info->bucket_offset, - bucket_info->bucket_origin, materialized_only, dum_rel->schemaname, dum_rel->relname, diff --git a/tsl/src/continuous_aggs/materialize.c b/tsl/src/continuous_aggs/materialize.c index abac43c0f6b..db91b0f2ded 100644 --- a/tsl/src/continuous_aggs/materialize.c +++ b/tsl/src/continuous_aggs/materialize.c @@ -38,7 +38,7 @@ static Datum internal_to_time_value_or_infinite(int64 internal, Oid time_type, * materialization support * ***************************/ -static void spi_update_materializations(Hypertable *mat_ht, ContinuousAgg *cagg, +static void spi_update_materializations(Hypertable *mat_ht, const ContinuousAgg *cagg, SchemaAndName partial_view, SchemaAndName materialization_table, const NameData *time_column_name, @@ -47,13 +47,15 @@ static void spi_delete_materializations(SchemaAndName materialization_table, const NameData *time_column_name, TimeRange invalidation_range, const char *const chunk_condition); -static void -spi_insert_materializations(Hypertable *mat_ht, ContinuousAgg *cagg, SchemaAndName partial_view, - SchemaAndName materialization_table, const NameData *time_column_name, - TimeRange materialization_range, const char *const chunk_condition); +static void spi_insert_materializations(Hypertable *mat_ht, const ContinuousAgg *cagg, + SchemaAndName partial_view, + SchemaAndName materialization_table, + const NameData *time_column_name, + TimeRange materialization_range, + const char *const chunk_condition); void -continuous_agg_update_materialization(Hypertable *mat_ht, ContinuousAgg *cagg, +continuous_agg_update_materialization(Hypertable *mat_ht, const ContinuousAgg *cagg, SchemaAndName partial_view, SchemaAndName materialization_table, const NameData *time_column_name, @@ -220,9 +222,10 @@ internal_time_range_to_time_range(InternalTimeRange internal) } static void -spi_update_materializations(Hypertable *mat_ht, ContinuousAgg *cagg, SchemaAndName partial_view, - SchemaAndName materialization_table, const NameData *time_column_name, - TimeRange invalidation_range, const int32 chunk_id) +spi_update_materializations(Hypertable *mat_ht, const ContinuousAgg *cagg, + SchemaAndName partial_view, SchemaAndName materialization_table, + const NameData *time_column_name, TimeRange invalidation_range, + const int32 chunk_id) { StringInfo chunk_condition = makeStringInfo(); @@ -290,9 +293,10 @@ spi_delete_materializations(SchemaAndName materialization_table, const NameData } static void -spi_insert_materializations(Hypertable *mat_ht, ContinuousAgg *cagg, SchemaAndName partial_view, - SchemaAndName materialization_table, const NameData *time_column_name, - TimeRange materialization_range, const char *const chunk_condition) +spi_insert_materializations(Hypertable *mat_ht, const ContinuousAgg *cagg, + SchemaAndName partial_view, SchemaAndName materialization_table, + const NameData *time_column_name, TimeRange materialization_range, + const char *const chunk_condition) { int res; StringInfo command = makeStringInfo(); diff --git a/tsl/src/continuous_aggs/materialize.h b/tsl/src/continuous_aggs/materialize.h index 8848f1d5f09..baffaf05f86 100644 --- a/tsl/src/continuous_aggs/materialize.h +++ b/tsl/src/continuous_aggs/materialize.h @@ -35,7 +35,7 @@ typedef struct InternalTimeRange int64 end; /* exclusive */ } InternalTimeRange; -void continuous_agg_update_materialization(Hypertable *mat_ht, ContinuousAgg *cagg, +void continuous_agg_update_materialization(Hypertable *mat_ht, const ContinuousAgg *cagg, SchemaAndName partial_view, SchemaAndName materialization_table, const NameData *time_column_name, diff --git a/tsl/src/continuous_aggs/refresh.c b/tsl/src/continuous_aggs/refresh.c index a1f016734d0..c2df93ac25c 100644 --- a/tsl/src/continuous_aggs/refresh.c +++ b/tsl/src/continuous_aggs/refresh.c @@ -43,14 +43,17 @@ typedef struct CaggRefreshState static Hypertable *cagg_get_hypertable_or_fail(int32 hypertable_id); static InternalTimeRange get_largest_bucketed_window(Oid timetype, int64 bucket_width); -static InternalTimeRange compute_inscribed_bucketed_refresh_window( - ContinuousAgg *cagg, const InternalTimeRange *const refresh_window, const int64 bucket_width); -static InternalTimeRange compute_circumscribed_bucketed_refresh_window( - ContinuousAgg *cagg, const InternalTimeRange *const refresh_window, const int64 bucket_width, - const ContinuousAggsBucketFunction *bucket_function); +static InternalTimeRange +compute_inscribed_bucketed_refresh_window(const ContinuousAgg *cagg, + const InternalTimeRange *const refresh_window, + const int64 bucket_width); +static InternalTimeRange +compute_circumscribed_bucketed_refresh_window(const ContinuousAgg *cagg, + const InternalTimeRange *const refresh_window, + const ContinuousAggsBucketFunction *bucket_function); static void continuous_agg_refresh_init(CaggRefreshState *refresh, const ContinuousAgg *cagg, const InternalTimeRange *refresh_window); -static void continuous_agg_refresh_execute(CaggRefreshState *refresh, +static void continuous_agg_refresh_execute(const CaggRefreshState *refresh, const InternalTimeRange *bucketed_refresh_window, const int32 chunk_id); static void log_refresh_window(int elevel, const ContinuousAgg *cagg, @@ -70,7 +73,7 @@ static void continuous_agg_refresh_with_window(const ContinuousAgg *cagg, const CaggRefreshCallContext callctx); static ContinuousAgg *get_cagg_by_relid(const Oid cagg_relid); static void emit_up_to_date_notice(const ContinuousAgg *cagg, const CaggRefreshCallContext callctx); -static bool process_cagg_invalidations_and_refresh(ContinuousAgg *cagg, +static bool process_cagg_invalidations_and_refresh(const ContinuousAgg *cagg, const InternalTimeRange *refresh_window, const CaggRefreshCallContext callctx, int32 chunk_id); @@ -143,7 +146,7 @@ get_largest_bucketed_window(Oid timetype, int64 bucket_width) * where part of its data were dropped by a retention policy. See #2198 for details. */ static InternalTimeRange -compute_inscribed_bucketed_refresh_window(ContinuousAgg *cagg, +compute_inscribed_bucketed_refresh_window(const ContinuousAgg *cagg, const InternalTimeRange *const refresh_window, const int64 bucket_width) { @@ -154,9 +157,10 @@ compute_inscribed_bucketed_refresh_window(ContinuousAgg *cagg, NullableDatum offset = { .value = 0, .isnull = true }; NullableDatum null_datum = { .value = 0, .isnull = true }; - if (cagg != NULL && cagg->data.bucket_offset != NULL && cagg->data.bucket_offset != 0) + if (cagg != NULL && cagg->bucket_function != NULL && + cagg->bucket_function->bucket_time_offset != 0) { - offset.value = IntervalPGetDatum(cagg->data.bucket_offset); + offset.value = IntervalPGetDatum(cagg->bucket_function->bucket_time_offset); offset.isnull = true; } @@ -225,13 +229,12 @@ compute_inscribed_bucketed_refresh_window(ContinuousAgg *cagg, * dropping chunks manually or as part of retention policy. */ static InternalTimeRange -compute_circumscribed_bucketed_refresh_window(ContinuousAgg *cagg, +compute_circumscribed_bucketed_refresh_window(const ContinuousAgg *cagg, const InternalTimeRange *const refresh_window, - const int64 bucket_width, const ContinuousAggsBucketFunction *bucket_function) { /* TODO FIXME */ - if (bucket_width == BUCKET_WIDTH_VARIABLE) + if (bucket_function->bucket_fixed_interval == false) { InternalTimeRange result = *refresh_window; ts_compute_circumscribed_bucketed_refresh_window_variable(&result.start, @@ -321,7 +324,7 @@ continuous_agg_refresh_init(CaggRefreshState *refresh, const ContinuousAgg *cagg * refresh state. */ static void -continuous_agg_refresh_execute(CaggRefreshState *refresh, +continuous_agg_refresh_execute(const CaggRefreshState *refresh, const InternalTimeRange *bucketed_refresh_window, const int32 chunk_id) { @@ -415,7 +418,7 @@ update_merged_refresh_window(const InternalTimeRange *bucketed_refresh_window, } static long -continuous_agg_scan_refresh_window_ranges(ContinuousAgg *cagg, +continuous_agg_scan_refresh_window_ranges(const ContinuousAgg *cagg, const InternalTimeRange *refresh_window, const InvalidationStore *invalidations, const ContinuousAggsBucketFunction *bucket_function, @@ -452,10 +455,7 @@ continuous_agg_scan_refresh_window_ranges(ContinuousAgg *cagg, }; InternalTimeRange bucketed_refresh_window = - compute_circumscribed_bucketed_refresh_window(cagg, - &invalidation, - bucket_width, - bucket_function); + compute_circumscribed_bucketed_refresh_window(cagg, &invalidation, bucket_function); (*exec_func)(&bucketed_refresh_window, callctx, count, func_arg1, func_arg2); @@ -494,22 +494,12 @@ continuous_agg_scan_refresh_window_ranges(ContinuousAgg *cagg, * as illustrated above. */ static void -<<<<<<< HEAD continuous_agg_refresh_with_window(const ContinuousAgg *cagg, const InternalTimeRange *refresh_window, const InvalidationStore *invalidations, int32 chunk_id, const bool do_merged_refresh, -<<<<<<< HEAD const InternalTimeRange merged_refresh_window, const CaggRefreshCallContext callctx) -======= -======= -continuous_agg_refresh_with_window(ContinuousAgg *cagg, const InternalTimeRange *refresh_window, - const InvalidationStore *invalidations, const int64 bucket_width, - int32 chunk_id, const bool do_merged_refresh, ->>>>>>> fd503c804 (Support for CAgg with origin/offset parameter) - const InternalTimeRange merged_refresh_window) ->>>>>>> cb1a2f41b (Support for CAgg with origin/offset parameter) { CaggRefreshState refresh; @@ -668,7 +658,8 @@ continuous_agg_calculate_merged_refresh_window(const int32 raw_hypertable_id, } static bool -process_cagg_invalidations_and_refresh(ContinuousAgg *cagg, const InternalTimeRange *refresh_window, +process_cagg_invalidations_and_refresh(const ContinuousAgg *cagg, + const InternalTimeRange *refresh_window, const CaggRefreshCallContext callctx, int32 chunk_id) { InvalidationStore *invalidations; @@ -723,7 +714,8 @@ process_cagg_invalidations_and_refresh(ContinuousAgg *cagg, const InternalTimeRa } void -continuous_agg_refresh_internal(ContinuousAgg *cagg, const InternalTimeRange *refresh_window_arg, +continuous_agg_refresh_internal(const ContinuousAgg *cagg, + const InternalTimeRange *refresh_window_arg, const CaggRefreshCallContext callctx, const bool start_isnull, const bool end_isnull) { @@ -773,13 +765,7 @@ continuous_agg_refresh_internal(ContinuousAgg *cagg, const InternalTimeRange *re int64 bucket_width = ts_continuous_agg_fixed_bucket_width(cagg->bucket_function); Assert(bucket_width > 0); refresh_window = -<<<<<<< HEAD - compute_inscribed_bucketed_refresh_window(refresh_window_arg, bucket_width); -======= - compute_inscribed_bucketed_refresh_window(cagg, - refresh_window_arg, - ts_continuous_agg_bucket_width(cagg)); ->>>>>>> fd503c804 (Support for CAgg with origin/offset parameter) + compute_inscribed_bucketed_refresh_window(cagg, refresh_window_arg, bucket_width); } } diff --git a/tsl/src/continuous_aggs/refresh.h b/tsl/src/continuous_aggs/refresh.h index 52512ded3cf..9774ce61220 100644 --- a/tsl/src/continuous_aggs/refresh.h +++ b/tsl/src/continuous_aggs/refresh.h @@ -14,9 +14,9 @@ extern Datum continuous_agg_refresh(PG_FUNCTION_ARGS); extern void continuous_agg_calculate_merged_refresh_window( - const InternalTimeRange *refresh_window, const InvalidationStore *invalidations, - const ContinuousAggsBucketFunction *bucket_function, InternalTimeRange *merged_refresh_window, - const CaggRefreshCallContext callctx); + const int32 raw_hypertable_id, const InternalTimeRange *refresh_window, + const InvalidationStore *invalidations, const ContinuousAggsBucketFunction *bucket_function, + InternalTimeRange *merged_refresh_window, const CaggRefreshCallContext callctx); extern void continuous_agg_refresh_internal(const ContinuousAgg *cagg, const InternalTimeRange *refresh_window, const CaggRefreshCallContext callctx, diff --git a/tsl/test/expected/cagg_bgw-13.out b/tsl/test/expected/cagg_bgw-13.out index c36c44377c7..cbf9d942037 100644 --- a/tsl/test/expected/cagg_bgw-13.out +++ b/tsl/test/expected/cagg_bgw-13.out @@ -67,8 +67,8 @@ SELECT * FROM timescaledb_information.job_stats; (0 rows) SELECT * FROM _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 | bucket_width | direct_view_schema | direct_view_name | materialized_only | finalized --------------------+-------------------+--------------------------+------------------+----------------+---------------------+-------------------+--------------+--------------------+------------------+-------------------+----------- + 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 +-------------------+-------------------+--------------------------+------------------+----------------+---------------------+-------------------+--------------------+------------------+-------------------+----------- (0 rows) -- though user on access node has required GRANTS, this will propagate GRANTS to the connected data nodes @@ -103,11 +103,16 @@ SELECT add_continuous_aggregate_policy('test_continuous_agg_view', NULL, 4::inte SELECT id as raw_table_id FROM _timescaledb_catalog.hypertable WHERE table_name='test_continuous_agg_table' \gset -- min distance from end should be 1 -SELECT mat_hypertable_id, user_view_schema, user_view_name, bucket_width -FROM _timescaledb_catalog.continuous_agg; - mat_hypertable_id | user_view_schema | user_view_name | bucket_width --------------------+------------------+--------------------------+-------------- - 2 | public | test_continuous_agg_view | 2 +SELECT mat_hypertable_id, user_view_schema, user_view_name FROM _timescaledb_catalog.continuous_agg; + mat_hypertable_id | user_view_schema | user_view_name +-------------------+------------------+-------------------------- + 2 | public | test_continuous_agg_view +(1 row) + +SELECT mat_hypertable_id, bucket_width FROM _timescaledb_catalog.continuous_aggs_bucket_function; + mat_hypertable_id | bucket_width +-------------------+-------------- + 2 | 2 (1 row) SELECT mat_hypertable_id FROM _timescaledb_catalog.continuous_agg \gset diff --git a/tsl/test/expected/cagg_bgw-14.out b/tsl/test/expected/cagg_bgw-14.out index c36c44377c7..cbf9d942037 100644 --- a/tsl/test/expected/cagg_bgw-14.out +++ b/tsl/test/expected/cagg_bgw-14.out @@ -67,8 +67,8 @@ SELECT * FROM timescaledb_information.job_stats; (0 rows) SELECT * FROM _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 | bucket_width | direct_view_schema | direct_view_name | materialized_only | finalized --------------------+-------------------+--------------------------+------------------+----------------+---------------------+-------------------+--------------+--------------------+------------------+-------------------+----------- + 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 +-------------------+-------------------+--------------------------+------------------+----------------+---------------------+-------------------+--------------------+------------------+-------------------+----------- (0 rows) -- though user on access node has required GRANTS, this will propagate GRANTS to the connected data nodes @@ -103,11 +103,16 @@ SELECT add_continuous_aggregate_policy('test_continuous_agg_view', NULL, 4::inte SELECT id as raw_table_id FROM _timescaledb_catalog.hypertable WHERE table_name='test_continuous_agg_table' \gset -- min distance from end should be 1 -SELECT mat_hypertable_id, user_view_schema, user_view_name, bucket_width -FROM _timescaledb_catalog.continuous_agg; - mat_hypertable_id | user_view_schema | user_view_name | bucket_width --------------------+------------------+--------------------------+-------------- - 2 | public | test_continuous_agg_view | 2 +SELECT mat_hypertable_id, user_view_schema, user_view_name FROM _timescaledb_catalog.continuous_agg; + mat_hypertable_id | user_view_schema | user_view_name +-------------------+------------------+-------------------------- + 2 | public | test_continuous_agg_view +(1 row) + +SELECT mat_hypertable_id, bucket_width FROM _timescaledb_catalog.continuous_aggs_bucket_function; + mat_hypertable_id | bucket_width +-------------------+-------------- + 2 | 2 (1 row) SELECT mat_hypertable_id FROM _timescaledb_catalog.continuous_agg \gset diff --git a/tsl/test/expected/cagg_bgw-15.out b/tsl/test/expected/cagg_bgw-15.out index c36c44377c7..cbf9d942037 100644 --- a/tsl/test/expected/cagg_bgw-15.out +++ b/tsl/test/expected/cagg_bgw-15.out @@ -67,8 +67,8 @@ SELECT * FROM timescaledb_information.job_stats; (0 rows) SELECT * FROM _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 | bucket_width | direct_view_schema | direct_view_name | materialized_only | finalized --------------------+-------------------+--------------------------+------------------+----------------+---------------------+-------------------+--------------+--------------------+------------------+-------------------+----------- + 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 +-------------------+-------------------+--------------------------+------------------+----------------+---------------------+-------------------+--------------------+------------------+-------------------+----------- (0 rows) -- though user on access node has required GRANTS, this will propagate GRANTS to the connected data nodes @@ -103,11 +103,16 @@ SELECT add_continuous_aggregate_policy('test_continuous_agg_view', NULL, 4::inte SELECT id as raw_table_id FROM _timescaledb_catalog.hypertable WHERE table_name='test_continuous_agg_table' \gset -- min distance from end should be 1 -SELECT mat_hypertable_id, user_view_schema, user_view_name, bucket_width -FROM _timescaledb_catalog.continuous_agg; - mat_hypertable_id | user_view_schema | user_view_name | bucket_width --------------------+------------------+--------------------------+-------------- - 2 | public | test_continuous_agg_view | 2 +SELECT mat_hypertable_id, user_view_schema, user_view_name FROM _timescaledb_catalog.continuous_agg; + mat_hypertable_id | user_view_schema | user_view_name +-------------------+------------------+-------------------------- + 2 | public | test_continuous_agg_view +(1 row) + +SELECT mat_hypertable_id, bucket_width FROM _timescaledb_catalog.continuous_aggs_bucket_function; + mat_hypertable_id | bucket_width +-------------------+-------------- + 2 | 2 (1 row) SELECT mat_hypertable_id FROM _timescaledb_catalog.continuous_agg \gset diff --git a/tsl/test/expected/cagg_bgw-16.out b/tsl/test/expected/cagg_bgw-16.out index 49e40f3e3a3..d156c791a71 100644 --- a/tsl/test/expected/cagg_bgw-16.out +++ b/tsl/test/expected/cagg_bgw-16.out @@ -67,8 +67,8 @@ SELECT * FROM timescaledb_information.job_stats; (0 rows) SELECT * FROM _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 | bucket_width | direct_view_schema | direct_view_name | materialized_only | finalized --------------------+-------------------+--------------------------+------------------+----------------+---------------------+-------------------+--------------+--------------------+------------------+-------------------+----------- + 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 +-------------------+-------------------+--------------------------+------------------+----------------+---------------------+-------------------+--------------------+------------------+-------------------+----------- (0 rows) -- though user on access node has required GRANTS, this will propagate GRANTS to the connected data nodes @@ -103,11 +103,16 @@ SELECT add_continuous_aggregate_policy('test_continuous_agg_view', NULL, 4::inte SELECT id as raw_table_id FROM _timescaledb_catalog.hypertable WHERE table_name='test_continuous_agg_table' \gset -- min distance from end should be 1 -SELECT mat_hypertable_id, user_view_schema, user_view_name, bucket_width -FROM _timescaledb_catalog.continuous_agg; - mat_hypertable_id | user_view_schema | user_view_name | bucket_width --------------------+------------------+--------------------------+-------------- - 2 | public | test_continuous_agg_view | 2 +SELECT mat_hypertable_id, user_view_schema, user_view_name FROM _timescaledb_catalog.continuous_agg; + mat_hypertable_id | user_view_schema | user_view_name +-------------------+------------------+-------------------------- + 2 | public | test_continuous_agg_view +(1 row) + +SELECT mat_hypertable_id, bucket_width FROM _timescaledb_catalog.continuous_aggs_bucket_function; + mat_hypertable_id | bucket_width +-------------------+-------------- + 2 | 2 (1 row) SELECT mat_hypertable_id FROM _timescaledb_catalog.continuous_agg \gset diff --git a/tsl/test/expected/cagg_watermark-13.out b/tsl/test/expected/cagg_watermark-13.out index d51d4a15f54..41184f6ac40 100644 --- a/tsl/test/expected/cagg_watermark-13.out +++ b/tsl/test/expected/cagg_watermark-13.out @@ -3,7 +3,7 @@ -- LICENSE-TIMESCALE for a copy of the license. \set EXPLAIN_ANALYZE 'EXPLAIN (analyze,costs off,timing off,summary off)' CREATE TABLE continuous_agg_test(time int, data int); -select create_hypertable('continuous_agg_test', 'time', chunk_time_interval=> 10); +SELECT create_hypertable('continuous_agg_test', 'time', chunk_time_interval=> 10); NOTICE: adding not-null constraint to column "time" create_hypertable ---------------------------------- @@ -42,14 +42,14 @@ SELECT * from _timescaledb_catalog.continuous_aggs_hypertable_invalidation_log; \c :TEST_DBNAME :ROLE_SUPERUSER CREATE TABLE continuous_agg_test_mat(time int); -select create_hypertable('continuous_agg_test_mat', 'time', chunk_time_interval=> 10); +SELECT create_hypertable('continuous_agg_test_mat', 'time', chunk_time_interval=> 10); NOTICE: adding not-null constraint to column "time" create_hypertable -------------------------------------- (2,public,continuous_agg_test_mat,t) (1 row) -INSERT INTO _timescaledb_catalog.continuous_agg VALUES (2, 1, NULL, '','','','',0,'',''); +INSERT INTO _timescaledb_catalog.continuous_agg VALUES (2, 1, NULL, '', '', '', '', '', ''); \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER -- create the trigger CREATE TRIGGER continuous_agg_insert_trigger diff --git a/tsl/test/expected/cagg_watermark-14.out b/tsl/test/expected/cagg_watermark-14.out index d51d4a15f54..41184f6ac40 100644 --- a/tsl/test/expected/cagg_watermark-14.out +++ b/tsl/test/expected/cagg_watermark-14.out @@ -3,7 +3,7 @@ -- LICENSE-TIMESCALE for a copy of the license. \set EXPLAIN_ANALYZE 'EXPLAIN (analyze,costs off,timing off,summary off)' CREATE TABLE continuous_agg_test(time int, data int); -select create_hypertable('continuous_agg_test', 'time', chunk_time_interval=> 10); +SELECT create_hypertable('continuous_agg_test', 'time', chunk_time_interval=> 10); NOTICE: adding not-null constraint to column "time" create_hypertable ---------------------------------- @@ -42,14 +42,14 @@ SELECT * from _timescaledb_catalog.continuous_aggs_hypertable_invalidation_log; \c :TEST_DBNAME :ROLE_SUPERUSER CREATE TABLE continuous_agg_test_mat(time int); -select create_hypertable('continuous_agg_test_mat', 'time', chunk_time_interval=> 10); +SELECT create_hypertable('continuous_agg_test_mat', 'time', chunk_time_interval=> 10); NOTICE: adding not-null constraint to column "time" create_hypertable -------------------------------------- (2,public,continuous_agg_test_mat,t) (1 row) -INSERT INTO _timescaledb_catalog.continuous_agg VALUES (2, 1, NULL, '','','','',0,'',''); +INSERT INTO _timescaledb_catalog.continuous_agg VALUES (2, 1, NULL, '', '', '', '', '', ''); \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER -- create the trigger CREATE TRIGGER continuous_agg_insert_trigger diff --git a/tsl/test/expected/cagg_watermark-15.out b/tsl/test/expected/cagg_watermark-15.out index 179cb80b10e..8800c7c5125 100644 --- a/tsl/test/expected/cagg_watermark-15.out +++ b/tsl/test/expected/cagg_watermark-15.out @@ -3,7 +3,7 @@ -- LICENSE-TIMESCALE for a copy of the license. \set EXPLAIN_ANALYZE 'EXPLAIN (analyze,costs off,timing off,summary off)' CREATE TABLE continuous_agg_test(time int, data int); -select create_hypertable('continuous_agg_test', 'time', chunk_time_interval=> 10); +SELECT create_hypertable('continuous_agg_test', 'time', chunk_time_interval=> 10); NOTICE: adding not-null constraint to column "time" create_hypertable ---------------------------------- @@ -42,14 +42,14 @@ SELECT * from _timescaledb_catalog.continuous_aggs_hypertable_invalidation_log; \c :TEST_DBNAME :ROLE_SUPERUSER CREATE TABLE continuous_agg_test_mat(time int); -select create_hypertable('continuous_agg_test_mat', 'time', chunk_time_interval=> 10); +SELECT create_hypertable('continuous_agg_test_mat', 'time', chunk_time_interval=> 10); NOTICE: adding not-null constraint to column "time" create_hypertable -------------------------------------- (2,public,continuous_agg_test_mat,t) (1 row) -INSERT INTO _timescaledb_catalog.continuous_agg VALUES (2, 1, NULL, '','','','',0,'',''); +INSERT INTO _timescaledb_catalog.continuous_agg VALUES (2, 1, NULL, '', '', '', '', '', ''); \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER -- create the trigger CREATE TRIGGER continuous_agg_insert_trigger diff --git a/tsl/test/expected/cagg_watermark-16.out b/tsl/test/expected/cagg_watermark-16.out index 179cb80b10e..8800c7c5125 100644 --- a/tsl/test/expected/cagg_watermark-16.out +++ b/tsl/test/expected/cagg_watermark-16.out @@ -3,7 +3,7 @@ -- LICENSE-TIMESCALE for a copy of the license. \set EXPLAIN_ANALYZE 'EXPLAIN (analyze,costs off,timing off,summary off)' CREATE TABLE continuous_agg_test(time int, data int); -select create_hypertable('continuous_agg_test', 'time', chunk_time_interval=> 10); +SELECT create_hypertable('continuous_agg_test', 'time', chunk_time_interval=> 10); NOTICE: adding not-null constraint to column "time" create_hypertable ---------------------------------- @@ -42,14 +42,14 @@ SELECT * from _timescaledb_catalog.continuous_aggs_hypertable_invalidation_log; \c :TEST_DBNAME :ROLE_SUPERUSER CREATE TABLE continuous_agg_test_mat(time int); -select create_hypertable('continuous_agg_test_mat', 'time', chunk_time_interval=> 10); +SELECT create_hypertable('continuous_agg_test_mat', 'time', chunk_time_interval=> 10); NOTICE: adding not-null constraint to column "time" create_hypertable -------------------------------------- (2,public,continuous_agg_test_mat,t) (1 row) -INSERT INTO _timescaledb_catalog.continuous_agg VALUES (2, 1, NULL, '','','','',0,'',''); +INSERT INTO _timescaledb_catalog.continuous_agg VALUES (2, 1, NULL, '', '', '', '', '', ''); \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER -- create the trigger CREATE TRIGGER continuous_agg_insert_trigger diff --git a/tsl/test/expected/exp_cagg_monthly.out b/tsl/test/expected/exp_cagg_monthly.out index a6579b528be..a4284bf176c 100644 --- a/tsl/test/expected/exp_cagg_monthly.out +++ b/tsl/test/expected/exp_cagg_monthly.out @@ -62,14 +62,6 @@ SELECT raw_hypertable_id AS ht_id FROM _timescaledb_catalog.continuous_agg WHERE user_view_name = 'conditions_summary' \gset -SELECT bucket_width -FROM _timescaledb_catalog.continuous_agg -WHERE mat_hypertable_id = :cagg_id; - bucket_width --------------- - -1 -(1 row) - \pset null SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function @@ -325,8 +317,8 @@ DROP MATERIALIZED VIEW conditions_summary; NOTICE: drop cascades to 3 other objects SELECT * FROM _timescaledb_catalog.continuous_agg WHERE mat_hypertable_id = :cagg_id; - mat_hypertable_id | raw_hypertable_id | parent_mat_hypertable_id | user_view_schema | user_view_name | partial_view_schema | partial_view_name | bucket_width | direct_view_schema | direct_view_name | materialized_only | finalized --------------------+-------------------+--------------------------+------------------+----------------+---------------------+-------------------+--------------+--------------------+------------------+-------------------+----------- + 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 +-------------------+-------------------+--------------------------+------------------+----------------+---------------------+-------------------+--------------------+------------------+-------------------+----------- (0 rows) SELECT * FROM _timescaledb_catalog.continuous_aggs_bucket_function diff --git a/tsl/test/sql/cagg_watermark.sql.in b/tsl/test/sql/cagg_watermark.sql.in index 6172668e177..9f6f5893a1c 100644 --- a/tsl/test/sql/cagg_watermark.sql.in +++ b/tsl/test/sql/cagg_watermark.sql.in @@ -21,8 +21,8 @@ SELECT * from _timescaledb_catalog.continuous_aggs_hypertable_invalidation_log; \c :TEST_DBNAME :ROLE_SUPERUSER CREATE TABLE continuous_agg_test_mat(time int); -select create_hypertable('continuous_agg_test_mat', 'time', chunk_time_interval=> 10); -INSERT INTO _timescaledb_catalog.continuous_agg VALUES (2, 1, NULL, '', '', '', '', 0, NULL, NULL, '', ''); +SELECT create_hypertable('continuous_agg_test_mat', 'time', chunk_time_interval=> 10); +INSERT INTO _timescaledb_catalog.continuous_agg VALUES (2, 1, NULL, '', '', '', '', '', ''); \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER -- create the trigger