Add user view query definition for cont aggs

Add the query definition to
timescaledb_information.continuous_aggregates.

The user query (specified in the CREATE VIEW stmt of a continuous
aggregate) is transformed in the process of creating a continuous
aggregate and this modified query is saved in the pg_rewrite catalog
tables. In order to display the original query, we create an internal
view which is a replica of the user query. This is used to display the
definition in timescaledb_information.continuous_aggregates.

As an alternative we could save the original user query in our internal
catalogs.  But this approach involves replicating a lot of postgres code
and causes portability problems.
This commit is contained in:
gayyappan 2019-04-10 15:41:20 -04:00 committed by Matvey Arye
parent dc0e250428
commit b8f9b91e60
18 changed files with 378 additions and 109 deletions

View File

@ -230,7 +230,8 @@ CREATE TABLE IF NOT EXISTS _timescaledb_catalog.continuous_agg (
bucket_width BIGINT NOT NULL,
job_id INTEGER UNIQUE NOT NULL REFERENCES _timescaledb_config.bgw_job(id) ON DELETE RESTRICT,
refresh_lag BIGINT NOT NULL,
user_view_query TEXT NOT NULL, --is a pg_node_tree but we can't use that with dump/restore
direct_view_schema NAME NOT NULL,
direct_view_name NAME NOT NULL,
UNIQUE(user_view_schema, user_view_name),
UNIQUE(partial_view_schema, partial_view_name)
);

View File

@ -12,7 +12,8 @@ CREATE TABLE IF NOT EXISTS _timescaledb_catalog.continuous_agg (
bucket_width BIGINT NOT NULL,
job_id INTEGER UNIQUE NOT NULL REFERENCES _timescaledb_config.bgw_job(id) ON DELETE RESTRICT,
refresh_lag BIGINT NOT NULL,
user_view_query TEXT NOT NULL, --is a pg_node_tree but we can't use that with dump/restore
direct_view_schema NAME NOT NULL,
direct_view_name NAME NOT NULL,
UNIQUE(user_view_schema, user_view_name),
UNIQUE(partial_view_schema, partial_view_name)
);

View File

@ -59,7 +59,8 @@ CREATE OR REPLACE VIEW timescaledb_information.continuous_aggregates as
viewinfo.viewowner as view_owner,
cagg.refresh_lag,
bgwjob.schedule_interval as refresh_interval,
format('%1$I.%2$I', ht.schema_name, ht.table_name)::regclass as materialization_hypertable
format('%1$I.%2$I', ht.schema_name, ht.table_name)::regclass as materialization_hypertable,
directview.viewdefinition as view_definition
FROM _timescaledb_catalog.continuous_agg cagg,
_timescaledb_catalog.hypertable ht, LATERAL
( select C.oid, pg_get_userbyid( C.relowner) as viewowner
@ -68,7 +69,11 @@ CREATE OR REPLACE VIEW timescaledb_information.continuous_aggregates as
and N.nspname = cagg.user_view_schema ) viewinfo, LATERAL
( select schedule_interval
FROM _timescaledb_config.bgw_job
where id = cagg.job_id ) bgwjob
where id = cagg.job_id ) bgwjob, LATERAL
( select pg_get_viewdef(C.oid) as viewdefinition
FROM pg_class C LEFT JOIN pg_namespace N on (N.oid = C.relnamespace)
where C.relkind = 'v' and C.relname = cagg.direct_view_name
and N.nspname = cagg.direct_view_schema ) directview
WHERE cagg.mat_hypertable_id = ht.id;
CREATE OR REPLACE VIEW timescaledb_information.continuous_aggregate_stats as

View File

@ -796,7 +796,8 @@ typedef enum Anum_continuous_agg
Anum_continuous_agg_bucket_width,
Anum_continuous_agg_job_id,
Anum_continuous_agg_refresh_lag,
Anum_continuous_agg_user_view_query,
Anum_continuous_agg_direct_view_schema,
Anum_continuous_agg_direct_view_name,
_Anum_continuous_agg_max,
} Anum_continuous_agg;
@ -813,7 +814,8 @@ typedef struct FormData_continuous_agg
int64 bucket_width;
int32 job_id;
int64 refresh_lag;
void *user_view_query; /* use heap_get_attr to access this */
NameData direct_view_schema;
NameData direct_view_name;
} FormData_continuous_agg;
typedef FormData_continuous_agg *Form_continuous_agg;

View File

@ -30,6 +30,8 @@
#include <utils/fmgrprotos.h>
#endif
#define CHECK_NAME_MATCH(name1, name2) (namestrcmp(name1, name2) == 0)
static const WithClauseDefinition continuous_aggregate_with_clause_def[] = {
[ContinuousEnabled] = {
.arg_name = "continuous",
@ -243,8 +245,8 @@ ts_continuous_agg_find_by_view_name(const char *schema, const char *name)
{
FormData_continuous_agg *data =
(FormData_continuous_agg *) GETSTRUCT(ts_scan_iterator_tuple(&iterator));
if (ts_continuous_agg_is_user_view(data, schema, name) ||
ts_continuous_agg_is_partial_view(data, schema, name))
ContinuousAggViewType vtyp = ts_continuous_agg_view_type(data, schema, name);
if (vtyp != ContinuousAggNone)
{
ca = palloc0(sizeof(*ca));
continuous_agg_init(ca, data);
@ -260,9 +262,10 @@ ts_continuous_agg_find_by_view_name(const char *schema, const char *name)
*
* These objects are: the user view itself, the catalog entry in
* continuous-agg , the partial view,
* the materialization hypertable and
* trigger on the raw hypertable (hypertable specified in the user view ).
* NOTE: The order in which the objects are dropped should be EXACTLy same as in materialize.c"
* the materialization hypertable,
* trigger on the raw hypertable (hypertable specified in the user view )
* copy of the user view query (aka the direct view)
* NOTE: The order in which the objects are dropped should be EXACTLY the same as in materialize.c"
*
* drop_user_view indicates whether to drop the user view.
* (should be false if called as part of the drop-user-view callback)
@ -274,7 +277,7 @@ drop_continuous_agg(ContinuousAgg *agg, bool drop_user_view)
ts_scan_iterator_create(CONTINUOUS_AGG, RowExclusiveLock, CurrentMemoryContext);
Catalog *catalog = ts_catalog_get();
ObjectAddress user_view = { .objectId = InvalidOid }, partial_view = { .objectId = InvalidOid },
rawht_trig = { .objectId = InvalidOid };
rawht_trig = { .objectId = InvalidOid }, direct_view = { .objectId = InvalidOid };
Hypertable *mat_hypertable, *raw_hypertable;
int32 count = 0;
bool raw_hypertable_has_other_caggs = true;
@ -341,6 +344,15 @@ drop_continuous_agg(ContinuousAgg *agg, bool drop_user_view)
if (OidIsValid(partial_view.objectId))
LockRelationOid(partial_view.objectId, AccessExclusiveLock);
direct_view = (ObjectAddress){
.classId = RelationRelationId,
.objectId =
get_relname_relid(NameStr(agg->data.direct_view_name),
get_namespace_oid(NameStr(agg->data.direct_view_schema), false)),
};
if (OidIsValid(direct_view.objectId))
LockRelationOid(direct_view.objectId, AccessExclusiveLock);
/* END OF LOCKING. Perform actual deletions now. */
if (OidIsValid(user_view.objectId))
@ -377,6 +389,8 @@ drop_continuous_agg(ContinuousAgg *agg, bool drop_user_view)
if (OidIsValid(partial_view.objectId))
performDeletion(&partial_view, DROP_RESTRICT, 0);
if (OidIsValid(direct_view.objectId))
performDeletion(&direct_view, DROP_RESTRICT, 0);
}
/*
@ -412,9 +426,9 @@ ts_continuous_agg_drop_hypertable_callback(int32 hypertable_id)
}
}
/* Block dropping the partial view if the continuous aggregate still exists */
/* Block dropping the partial and direct view if the continuous aggregate still exists */
static void
drop_partial_view(ContinuousAgg *agg)
drop_internal_view(ContinuousAgg *agg)
{
ScanIterator iterator =
ts_scan_iterator_create(CONTINUOUS_AGG, AccessShareLock, CurrentMemoryContext);
@ -429,47 +443,63 @@ drop_partial_view(ContinuousAgg *agg)
if (count > 0)
ereport(ERROR,
(errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
errmsg("cannot drop the partial view because it is required by a continuous "
"aggregate")));
errmsg(
"cannot drop the partial/direct view because it is required by a continuous "
"aggregate")));
}
/* This gets called when a view gets dropped. */
void
ts_continuous_agg_drop_view_callback(ContinuousAgg *ca, const char *schema, const char *name)
{
if (ts_continuous_agg_is_user_view(&ca->data, schema, name))
drop_continuous_agg(ca, false /* The user view has already been dropped */);
else if (ts_continuous_agg_is_partial_view(&ca->data, schema, name))
drop_partial_view(ca);
else
elog(ERROR, "unknown continuous aggregate view type");
ContinuousAggViewType vtyp;
vtyp = ts_continuous_agg_view_type(&ca->data, schema, name);
switch (vtyp)
{
case ContinuousAggUserView:
drop_continuous_agg(ca, false /* The user view has already been dropped */);
break;
case ContinuousAggPartialView:
case ContinuousAggDirectView:
drop_internal_view(ca);
break;
default:
elog(ERROR, "unknown continuous aggregate view type");
}
}
static inline bool
ts_continuous_agg_is_user_view_schema(FormData_continuous_agg *data, const char *schema)
{
return namestrcmp(&data->user_view_schema, schema) == 0;
return CHECK_NAME_MATCH(&data->user_view_schema, schema);
}
static inline bool
ts_continuous_agg_is_partial_view_schema(FormData_continuous_agg *data, const char *schema)
{
return namestrcmp(&data->partial_view_schema, schema) == 0;
return CHECK_NAME_MATCH(&data->partial_view_schema, schema);
}
bool
ts_continuous_agg_is_user_view(FormData_continuous_agg *data, const char *schema, const char *name)
static inline bool
ts_continuous_agg_is_direct_view_schema(FormData_continuous_agg *data, const char *schema)
{
return ts_continuous_agg_is_user_view_schema(data, schema) &&
(namestrcmp(&data->user_view_name, name) == 0);
return CHECK_NAME_MATCH(&data->direct_view_schema, schema);
}
bool
ts_continuous_agg_is_partial_view(FormData_continuous_agg *data, const char *schema,
const char *name)
ContinuousAggViewType
ts_continuous_agg_view_type(FormData_continuous_agg *data, const char *schema, const char *name)
{
return ts_continuous_agg_is_partial_view_schema(data, schema) &&
(namestrcmp(&data->partial_view_name, name) == 0);
if (CHECK_NAME_MATCH(&data->user_view_schema, schema) &&
CHECK_NAME_MATCH(&data->user_view_name, name))
return ContinuousAggUserView;
else if (CHECK_NAME_MATCH(&data->partial_view_schema, schema) &&
CHECK_NAME_MATCH(&data->partial_view_name, name))
return ContinuousAggPartialView;
else if (CHECK_NAME_MATCH(&data->direct_view_schema, schema) &&
CHECK_NAME_MATCH(&data->direct_view_name, name))
return ContinuousAggDirectView;
else
return ContinuousAggNone;
}
static FormData_continuous_agg *
@ -505,6 +535,12 @@ ts_continuous_agg_rename_schema_name(char *old_schema, char *new_schema)
namestrcpy(&new_data->partial_view_schema, new_schema);
}
if (ts_continuous_agg_is_direct_view_schema(data, old_schema))
{
FormData_continuous_agg *new_data = ensure_new_tuple(tinfo->tuple, &new_tuple);
namestrcpy(&new_data->direct_view_schema, new_schema);
}
if (new_tuple != NULL)
ts_catalog_update(tinfo->scanrel, new_tuple);
}
@ -522,19 +558,32 @@ ts_continuous_agg_rename_view(char *old_schema, char *name, char *new_schema, ch
TupleInfo *tinfo = ts_scan_iterator_tuple_info(&iterator);
FormData_continuous_agg *data = (FormData_continuous_agg *) GETSTRUCT(tinfo->tuple);
HeapTuple new_tuple = NULL;
if (ts_continuous_agg_is_user_view(data, old_schema, name))
ContinuousAggViewType vtyp = ts_continuous_agg_view_type(data, old_schema, name);
switch (vtyp)
{
FormData_continuous_agg *new_data = ensure_new_tuple(tinfo->tuple, &new_tuple);
namestrcpy(&new_data->user_view_schema, new_schema);
namestrcpy(&new_data->user_view_name, new_name);
}
if (ts_continuous_agg_is_partial_view(data, old_schema, name))
{
FormData_continuous_agg *new_data = ensure_new_tuple(tinfo->tuple, &new_tuple);
namestrcpy(&new_data->partial_view_schema, new_schema);
namestrcpy(&new_data->partial_view_name, new_name);
case ContinuousAggUserView:
{
FormData_continuous_agg *new_data = ensure_new_tuple(tinfo->tuple, &new_tuple);
namestrcpy(&new_data->user_view_schema, new_schema);
namestrcpy(&new_data->user_view_name, new_name);
break;
}
case ContinuousAggPartialView:
{
FormData_continuous_agg *new_data = ensure_new_tuple(tinfo->tuple, &new_tuple);
namestrcpy(&new_data->partial_view_schema, new_schema);
namestrcpy(&new_data->partial_view_name, new_name);
break;
}
case ContinuousAggDirectView:
{
FormData_continuous_agg *new_data = ensure_new_tuple(tinfo->tuple, &new_tuple);
namestrcpy(&new_data->direct_view_schema, new_schema);
namestrcpy(&new_data->direct_view_name, new_name);
break;
}
default:
break;
}
if (new_tuple != NULL)

View File

@ -23,6 +23,14 @@ typedef enum ContinuousAggViewOption
ContinuousViewOptionRefreshInterval,
} ContinuousAggViewOption;
typedef enum ContinuousAggViewType
{
ContinuousAggUserView = 0,
ContinuousAggPartialView,
ContinuousAggDirectView,
ContinuousAggNone
} ContinuousAggViewType;
extern TSDLLEXPORT WithClauseResult *ts_continuous_agg_with_clause_parse(const List *defelems);
typedef struct ContinuousAgg
@ -49,11 +57,9 @@ extern void ts_continuous_agg_drop_view_callback(ContinuousAgg *ca, const char *
extern void ts_continuous_agg_drop_hypertable_callback(int32 hypertable_id);
extern TSDLLEXPORT bool ts_continuous_agg_is_user_view(FormData_continuous_agg *data,
const char *schema, const char *name);
extern TSDLLEXPORT bool ts_continuous_agg_is_partial_view(FormData_continuous_agg *data,
const char *schema, const char *name);
extern TSDLLEXPORT ContinuousAggViewType ts_continuous_agg_view_type(FormData_continuous_agg *data,
const char *schema,
const char *name);
extern void ts_continuous_agg_rename_schema_name(char *old_schema, char *new_schema);
extern void ts_continuous_agg_rename_view(char *old_schema, char *name, char *new_schema,
char *new_name);

View File

@ -894,7 +894,7 @@ block_dropping_continuous_aggregates_without_cascade(ProcessUtilityArgs *args, D
if (cagg == NULL)
continue;
if (ts_continuous_agg_is_user_view(&cagg->data, schema, name))
if (ts_continuous_agg_view_type(&cagg->data, schema, name) == ContinuousAggUserView)
ereport(ERROR,
(errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
errmsg("dropping a continous aggregate requires using CASCADE")));
@ -2290,6 +2290,7 @@ process_altertable_start_view(ProcessUtilityArgs *args)
NameData view_schema;
ContinuousAgg *cagg;
ListCell *lc;
ContinuousAggViewType vtyp;
if (!OidIsValid(view_relid))
return false;
@ -2301,7 +2302,8 @@ process_altertable_start_view(ProcessUtilityArgs *args)
if (cagg == NULL)
return false;
if (ts_continuous_agg_is_partial_view(&cagg->data, NameStr(view_schema), NameStr(view_name)))
vtyp = ts_continuous_agg_view_type(&cagg->data, NameStr(view_schema), NameStr(view_name));
if (vtyp == ContinuousAggPartialView || vtyp == ContinuousAggDirectView)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot alter the internal view of a continuous aggregate")));

View File

@ -190,21 +190,22 @@ static Query *finalizequery_get_select_query(FinalizeQueryInfo *inp, List *matco
static void
create_cagg_catlog_entry(int32 matht_id, int32 rawht_id, char *user_schema, char *user_view,
char *partial_schema, char *partial_view, int64 bucket_width,
int64 refresh_lag, int32 job_id, Query *userquery_parse)
int64 refresh_lag, int32 job_id, char *direct_schema, char *direct_view)
{
Catalog *catalog = ts_catalog_get();
Relation rel;
TupleDesc desc;
NameData user_schnm, user_viewnm, partial_schnm, partial_viewnm;
NameData user_schnm, user_viewnm, partial_schnm, partial_viewnm, direct_schnm, direct_viewnm;
Datum values[Natts_continuous_agg];
bool nulls[Natts_continuous_agg] = { false };
CatalogSecurityContext sec_ctx;
char *userview_query = nodeToString(userquery_parse);
namestrcpy(&user_schnm, user_schema);
namestrcpy(&user_viewnm, user_view);
namestrcpy(&partial_schnm, partial_schema);
namestrcpy(&partial_viewnm, partial_view);
namestrcpy(&direct_schnm, direct_schema);
namestrcpy(&direct_viewnm, direct_view);
rel = heap_open(catalog_get_table_id(catalog, CONTINUOUS_AGG), RowExclusiveLock);
desc = RelationGetDescr(rel);
@ -222,8 +223,10 @@ create_cagg_catlog_entry(int32 matht_id, int32 rawht_id, char *user_schema, char
values[AttrNumberGetAttrOffset(Anum_continuous_agg_bucket_width)] = bucket_width;
values[AttrNumberGetAttrOffset(Anum_continuous_agg_job_id)] = job_id;
values[AttrNumberGetAttrOffset(Anum_continuous_agg_refresh_lag)] = refresh_lag;
values[AttrNumberGetAttrOffset(Anum_continuous_agg_user_view_query)] =
CStringGetTextDatum(userview_query);
values[AttrNumberGetAttrOffset(Anum_continuous_agg_direct_view_schema)] =
NameGetDatum(&direct_schnm);
values[AttrNumberGetAttrOffset(Anum_continuous_agg_direct_view_name)] =
NameGetDatum(&direct_viewnm);
ts_catalog_database_info_become_owner(ts_catalog_database_info_get(), &sec_ctx);
ts_catalog_insert_values(rel, desc, values, nulls);
@ -1334,6 +1337,34 @@ finalizequery_get_select_query(FinalizeQueryInfo *inp, List *matcollist,
return final_selquery;
}
/* assign aliases to the targetlist for the view query provided by the user
* we shoudl not reply on the default resnames say the query has : sum(temp), sum(humidity)
* the default resname is "sum" this would cause a conflict and create view will fail.
*/
static Query *
fixup_userview_query_tlist(Query *userquery, List *tlist_aliases)
{
Query *ret_query = copyObject(userquery);
if (tlist_aliases != NIL)
{
ListCell *lc;
ListCell *alist_item = list_head(tlist_aliases);
foreach (lc, ret_query->targetList)
{
TargetEntry *tle = (TargetEntry *) lfirst(lc);
/* junk columns don't get aliases */
if (tle->resjunk)
continue;
tle->resname = pstrdup(strVal(lfirst(alist_item)));
alist_item = lnext(alist_item);
if (alist_item == NULL)
break; /* done assigning aliases */
}
}
return ret_query;
}
/* Modifies the passed in ViewStmt to do the following
* a) Create a hypertable for the continuous agg materialization.
* b) create a view that references the underlying
@ -1378,10 +1409,11 @@ cagg_create(ViewStmt *stmt, Query *panquery, CAggTimebucketInfo *origquery_ht,
FinalizeQueryInfo finalqinfo;
Query *final_selquery;
Query *partial_selquery; /* query to populate the mattable*/
Query *partial_selquery; /* query to populate the mattable*/
Query *orig_userview_query; /* copy of the original user query for dummy view */
RangeTblEntry *usertbl_rte;
Oid nspid;
RangeVar *part_rel = NULL, *mat_rel = NULL;
RangeVar *part_rel = NULL, *mat_rel = NULL, *dum_rel = NULL;
int32 mat_htid;
int32 job_id;
char trigarg[NAMEDATALEN];
@ -1392,7 +1424,7 @@ cagg_create(ViewStmt *stmt, Query *panquery, CAggTimebucketInfo *origquery_ht,
origquery_ht->bucket_width,
with_clause_options);
mattablecolumninfo_init(&mattblinfo, NIL, NIL, panquery->groupClause);
mattablecolumninfo_init(&mattblinfo, NIL, NIL, copyObject(panquery->groupClause));
finalizequery_init(&finalqinfo, panquery, stmt->aliases, &mattblinfo);
/* invalidate all options on the stmt before using it
@ -1426,11 +1458,18 @@ cagg_create(ViewStmt *stmt, Query *panquery, CAggTimebucketInfo *origquery_ht,
PRINT_MATINTERNAL_NAME(relnamebuf, "ts_internal_%sview", stmt->view->relname);
part_rel = makeRangeVar(pstrdup(INTERNAL_SCHEMA_NAME), pstrdup(relnamebuf), -1);
create_view_for_query(partial_selquery, part_rel);
Assert(mat_rel != NULL);
/* Step 4a register the BGW job */
/* Additional miscellaneous steps */
/* create a dummy view to store the user supplied view query. This is to get PG
* to display the view correctly without having to replicate the PG source code for make_viewdef
*/
orig_userview_query = fixup_userview_query_tlist(panquery, stmt->aliases);
PRINT_MATINTERNAL_NAME(relnamebuf, "_dir_%sview", stmt->view->relname);
dum_rel = makeRangeVar(pstrdup(INTERNAL_SCHEMA_NAME), pstrdup(relnamebuf), -1);
create_view_for_query(orig_userview_query, dum_rel);
/* register the BGW job to process continuous aggs*/
job_id =
ts_continuous_agg_job_add(origquery_ht->htid, origquery_ht->bucket_width, refresh_interval);
@ -1445,9 +1484,10 @@ cagg_create(ViewStmt *stmt, Query *panquery, CAggTimebucketInfo *origquery_ht,
origquery_ht->bucket_width,
refresh_lag,
job_id,
panquery);
dum_rel->schemaname,
dum_rel->relname);
/* create trigger on raw hypertable -specified in the user view query*/
/* Step 5 create trigger on raw hypertable -specified in the user view query*/
ret = snprintf(trigarg, NAMEDATALEN, "%d", origquery_ht->htid);
if (ret < 0 || ret >= NAMEDATALEN)
ereport(ERROR,

View File

@ -65,8 +65,8 @@ SELECT * FROM timescaledb_information.policy_stats;
(0 rows)
SELECT * FROM _timescaledb_catalog.continuous_agg;
mat_hypertable_id | raw_hypertable_id | user_view_schema | user_view_name | partial_view_schema | partial_view_name | bucket_width | job_id | refresh_lag | user_view_query
-------------------+-------------------+------------------+----------------+---------------------+-------------------+--------------+--------+-------------+-----------------
mat_hypertable_id | raw_hypertable_id | user_view_schema | user_view_name | partial_view_schema | partial_view_name | bucket_width | job_id | refresh_lag | direct_view_schema | direct_view_name
-------------------+-------------------+------------------+----------------+---------------------+-------------------+--------------+--------+-------------+--------------------+------------------
(0 rows)
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
@ -168,8 +168,15 @@ refresh_lag | 4
refresh_interval | @ 12 hours
materialization_hypertable | _timescaledb_internal.ts_internal_test_continuous_agg_viewtab
--TODO
--select view_name, viewdefinition from timescaledb_information.continuous_aggregate_settings where view_name::text like '%test_continuous_agg_view';
select view_name, view_definition from timescaledb_information.continuous_aggregates
where view_name::text like '%test_continuous_agg_view';
-[ RECORD 1 ]---+--------------------------------------------------------------------------------
view_name | test_continuous_agg_view
view_definition | SELECT time_bucket(2, test_continuous_agg_table."time") AS time_partition_col,+
| sum(test_continuous_agg_table.data) AS value +
| FROM test_continuous_agg_table +
| GROUP BY (time_bucket(2, test_continuous_agg_table."time"));
select view_name, completed_threshold, invalidation_threshold, job_status, last_run_duration from timescaledb_information.continuous_aggregate_stats where view_name::text like '%test_continuous_agg_view';
-[ RECORD 1 ]----------+-------------------------
view_name | test_continuous_agg_view

View File

@ -149,7 +149,7 @@ order by 1;
-- TEST3 --
-- drop on table conditions should cascade to materialized mat_v1
drop table conditions cascade;
NOTICE: drop cascades to view _timescaledb_internal.ts_internal_mat_m1view
NOTICE: drop cascades to 2 other objects
NOTICE: drop cascades to 2 other objects
CREATE TABLE conditions (
timec TIMESTAMPTZ NOT NULL,
@ -307,7 +307,7 @@ order by sum(temperature)+sum(humidity);
--group by with more than 1 group column
-- having clause with a mix of columns from select list + others
drop table conditions cascade;
NOTICE: drop cascades to view _timescaledb_internal.ts_internal_mat_m1view
NOTICE: drop cascades to 2 other objects
NOTICE: drop cascades to 2 other objects
CREATE TABLE conditions (
timec TIMESTAMPTZ NOT NULL,
@ -388,6 +388,20 @@ order by time_bucket('1week', timec), min(location);
Sun Dec 30 16:00:00 2018 PST | NYC | 210 | 21.2132034355964
(3 rows)
--check view defintion in information views
select view_name, view_definition from timescaledb_information.continuous_aggregates
where view_name::text like 'mat_m1';
view_name | view_definition
-----------+-----------------------------------------------------------------------------------------------------------------
mat_m1 | SELECT time_bucket('@ 7 days'::interval, conditions.timec) AS timec, +
| min(conditions.location) AS minl, +
| (sum(conditions.temperature) + sum(conditions.humidity)) AS sumth, +
| stddev(conditions.humidity) AS stddevh +
| FROM conditions +
| GROUP BY (time_bucket('@ 7 days'::interval, conditions.timec)) +
| HAVING ((min(conditions.location) >= 'NYC'::text) AND (avg(conditions.temperature) > (20)::double precision));
(1 row)
--TEST6 -- select from internal view
\c :TEST_DBNAME :ROLE_SUPERUSER
insert into _timescaledb_internal.ts_internal_mat_m1tab
@ -457,7 +471,9 @@ psql:include/cont_agg_equal.sql:13: NOTICE: adding not-null constraint to colum
SELECT h.schema_name AS "MAT_SCHEMA_NAME",
h.table_name AS "MAT_TABLE_NAME",
partial_view_name as "PART_VIEW_NAME",
partial_view_schema as "PART_VIEW_SCHEMA"
partial_view_schema as "PART_VIEW_SCHEMA",
direct_view_name as "DIR_VIEW_NAME",
direct_view_schema as "DIR_VIEW_SCHEMA"
FROM _timescaledb_catalog.continuous_agg ca
INNER JOIN _timescaledb_catalog.hypertable h ON(h.id = ca.mat_hypertable_id)
WHERE user_view_name = 'mat_test'
@ -465,7 +481,9 @@ WHERE user_view_name = 'mat_test'
DROP TABLE :"MAT_SCHEMA_NAME".:"MAT_TABLE_NAME";
ERROR: cannot drop table _timescaledb_internal.ts_internal_mat_testtab because other objects depend on it
DROP VIEW :"PART_VIEW_SCHEMA".:"PART_VIEW_NAME";
ERROR: cannot drop the partial view because it is required by a continuous aggregate
ERROR: cannot drop the partial/direct view because it is required by a continuous aggregate
DROP VIEW :"DIR_VIEW_SCHEMA".:"DIR_VIEW_NAME";
ERROR: cannot drop the partial/direct view because it is required by a continuous aggregate
DROP VIEW mat_test;
ERROR: dropping a continous aggregate requires using CASCADE
\set ON_ERROR_STOP 1
@ -478,7 +496,7 @@ WHERE user_view_name = 'mat_test';
1
(1 row)
--mat table, user_view, and partial view all there
--mat table, user_view, direct view and partial view all there
select count(*) from pg_class where relname = :'PART_VIEW_NAME';
count
-------
@ -491,6 +509,12 @@ select count(*) from pg_class where relname = :'MAT_TABLE_NAME';
1
(1 row)
select count(*) from pg_class where relname = :'DIR_VIEW_NAME';
count
-------
1
(1 row)
select count(*) from pg_class where relname = 'mat_test';
count
-------
@ -508,7 +532,7 @@ WHERE user_view_name = 'mat_test';
0
(1 row)
--mat table, user_view, and partial view all gone
--mat table, user_view, direct view and partial view all gone
select count(*) from pg_class where relname = :'PART_VIEW_NAME';
count
-------
@ -521,6 +545,12 @@ select count(*) from pg_class where relname = :'MAT_TABLE_NAME';
0
(1 row)
select count(*) from pg_class where relname = :'DIR_VIEW_NAME';
count
-------
0
(1 row)
select count(*) from pg_class where relname = 'mat_test';
count
-------
@ -597,7 +627,7 @@ select count(*) from _timescaledb_catalog.continuous_aggs_hypertable_invalidatio
(1 row)
DROP TABLE conditions CASCADE;
NOTICE: drop cascades to view _timescaledb_internal.ts_internal_mat_drop_testview
NOTICE: drop cascades to 2 other objects
NOTICE: drop cascades to 2 other objects
--catalog entry should be gone
SELECT count(*)
@ -699,7 +729,7 @@ SELECT schedule_interval FROM _timescaledb_config.bgw_job;
(1 row)
DROP TABLE conditions CASCADE;
NOTICE: drop cascades to view _timescaledb_internal.ts_internal_mat_with_testview
NOTICE: drop cascades to 2 other objects
--test WITH using a hypertable with an integer time dimension
CREATE TABLE conditions (
timec INT NOT NULL,

View File

@ -83,6 +83,27 @@ SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name
rename_schema | rename_test | public | ts_internal_rename_testview
(2 rows)
--alter direct view schema
SELECT user_view_schema, user_view_name, direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
user_view_schema | user_view_name | direct_view_schema | direct_view_name
------------------+----------------+-----------------------+----------------------
public | mat_m1 | _timescaledb_internal | _dir_mat_m1view
rename_schema | rename_test | _timescaledb_internal | _dir_rename_testview
(2 rows)
\c :TEST_DBNAME :ROLE_SUPERUSER
ALTER VIEW _timescaledb_internal._dir_rename_testview SET SCHEMA public;
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name,
direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
user_view_schema | user_view_name | partial_view_schema | partial_view_name | direct_view_schema | direct_view_name
------------------+----------------+-----------------------+-----------------------------+-----------------------+----------------------
public | mat_m1 | _timescaledb_internal | ts_internal_mat_m1view | _timescaledb_internal | _dir_mat_m1view
rename_schema | rename_test | public | ts_internal_rename_testview | public | _dir_rename_testview
(2 rows)
\c :TEST_DBNAME :ROLE_SUPERUSER
ALTER SCHEMA rename_schema RENAME TO new_name_schema;
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
@ -149,19 +170,31 @@ SELECT * FROM rename_c_aggregate;
(0 rows)
ALTER VIEW rename_schema.ts_internal_rename_testview RENAME TO partial_view;
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name,
direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
user_view_schema | user_view_name | partial_view_schema | partial_view_name
------------------+--------------------+-----------------------+------------------------
public | mat_m1 | _timescaledb_internal | ts_internal_mat_m1view
public | rename_c_aggregate | rename_schema | partial_view
user_view_schema | user_view_name | partial_view_schema | partial_view_name | direct_view_schema | direct_view_name
------------------+--------------------+-----------------------+------------------------+-----------------------+----------------------
public | mat_m1 | _timescaledb_internal | ts_internal_mat_m1view | _timescaledb_internal | _dir_mat_m1view
public | rename_c_aggregate | rename_schema | partial_view | public | _dir_rename_testview
(2 rows)
--rename direct view
ALTER VIEW _dir_rename_testview RENAME TO direct_view;
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name,
direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
user_view_schema | user_view_name | partial_view_schema | partial_view_name | direct_view_schema | direct_view_name
------------------+--------------------+-----------------------+------------------------+-----------------------+------------------
public | mat_m1 | _timescaledb_internal | ts_internal_mat_m1view | _timescaledb_internal | _dir_mat_m1view
public | rename_c_aggregate | rename_schema | partial_view | public | direct_view
(2 rows)
-- drop_chunks tests
DROP TABLE conditions CASCADE;
NOTICE: drop cascades to view _timescaledb_internal.ts_internal_mat_m1view
NOTICE: drop cascades to 2 other objects
DROP TABLE foo CASCADE;
NOTICE: drop cascades to view rename_schema.partial_view
NOTICE: drop cascades to 2 other objects
CREATE TABLE drop_chunks_table(time BIGINT, data INTEGER);
SELECT hypertable_id AS drop_chunks_table_id
FROM create_hypertable('drop_chunks_table', 'time', chunk_time_interval => 10) \gset
@ -305,7 +338,7 @@ SELECT * FROM drop_chunks_view ORDER BY 1;
-- drop chunks when the chunksize and time_bucket aren't aligned
DROP TABLE drop_chunks_table CASCADE;
NOTICE: drop cascades to view _timescaledb_internal.ts_internal_drop_chunks_viewview
NOTICE: drop cascades to 2 other objects
NOTICE: drop cascades to table _timescaledb_internal._hyper_6_4_chunk
CREATE TABLE drop_chunks_table_u(time BIGINT, data INTEGER);
SELECT hypertable_id AS drop_chunks_table_u_id

View File

@ -83,6 +83,27 @@ SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name
rename_schema | rename_test | public | ts_internal_rename_testview
(2 rows)
--alter direct view schema
SELECT user_view_schema, user_view_name, direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
user_view_schema | user_view_name | direct_view_schema | direct_view_name
------------------+----------------+-----------------------+----------------------
public | mat_m1 | _timescaledb_internal | _dir_mat_m1view
rename_schema | rename_test | _timescaledb_internal | _dir_rename_testview
(2 rows)
\c :TEST_DBNAME :ROLE_SUPERUSER
ALTER VIEW _timescaledb_internal._dir_rename_testview SET SCHEMA public;
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name,
direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
user_view_schema | user_view_name | partial_view_schema | partial_view_name | direct_view_schema | direct_view_name
------------------+----------------+-----------------------+-----------------------------+-----------------------+----------------------
public | mat_m1 | _timescaledb_internal | ts_internal_mat_m1view | _timescaledb_internal | _dir_mat_m1view
rename_schema | rename_test | public | ts_internal_rename_testview | public | _dir_rename_testview
(2 rows)
\c :TEST_DBNAME :ROLE_SUPERUSER
ALTER SCHEMA rename_schema RENAME TO new_name_schema;
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
@ -149,19 +170,31 @@ SELECT * FROM rename_c_aggregate;
(0 rows)
ALTER VIEW rename_schema.ts_internal_rename_testview RENAME TO partial_view;
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name,
direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
user_view_schema | user_view_name | partial_view_schema | partial_view_name
------------------+--------------------+-----------------------+------------------------
public | mat_m1 | _timescaledb_internal | ts_internal_mat_m1view
public | rename_c_aggregate | rename_schema | partial_view
user_view_schema | user_view_name | partial_view_schema | partial_view_name | direct_view_schema | direct_view_name
------------------+--------------------+-----------------------+------------------------+-----------------------+----------------------
public | mat_m1 | _timescaledb_internal | ts_internal_mat_m1view | _timescaledb_internal | _dir_mat_m1view
public | rename_c_aggregate | rename_schema | partial_view | public | _dir_rename_testview
(2 rows)
--rename direct view
ALTER VIEW _dir_rename_testview RENAME TO direct_view;
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name,
direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
user_view_schema | user_view_name | partial_view_schema | partial_view_name | direct_view_schema | direct_view_name
------------------+--------------------+-----------------------+------------------------+-----------------------+------------------
public | mat_m1 | _timescaledb_internal | ts_internal_mat_m1view | _timescaledb_internal | _dir_mat_m1view
public | rename_c_aggregate | rename_schema | partial_view | public | direct_view
(2 rows)
-- drop_chunks tests
DROP TABLE conditions CASCADE;
NOTICE: drop cascades to view _timescaledb_internal.ts_internal_mat_m1view
NOTICE: drop cascades to 2 other objects
DROP TABLE foo CASCADE;
NOTICE: drop cascades to view rename_schema.partial_view
NOTICE: drop cascades to 2 other objects
CREATE TABLE drop_chunks_table(time BIGINT, data INTEGER);
SELECT hypertable_id AS drop_chunks_table_id
FROM create_hypertable('drop_chunks_table', 'time', chunk_time_interval => 10) \gset
@ -305,7 +338,7 @@ SELECT * FROM drop_chunks_view ORDER BY 1;
-- drop chunks when the chunksize and time_bucket aren't aligned
DROP TABLE drop_chunks_table CASCADE;
NOTICE: drop cascades to view _timescaledb_internal.ts_internal_drop_chunks_viewview
NOTICE: drop cascades to 2 other objects
NOTICE: drop cascades to table _timescaledb_internal._hyper_6_4_chunk
CREATE TABLE drop_chunks_table_u(time BIGINT, data INTEGER);
SELECT hypertable_id AS drop_chunks_table_u_id

View File

@ -83,6 +83,27 @@ SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name
rename_schema | rename_test | public | ts_internal_rename_testview
(2 rows)
--alter direct view schema
SELECT user_view_schema, user_view_name, direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
user_view_schema | user_view_name | direct_view_schema | direct_view_name
------------------+----------------+-----------------------+----------------------
public | mat_m1 | _timescaledb_internal | _dir_mat_m1view
rename_schema | rename_test | _timescaledb_internal | _dir_rename_testview
(2 rows)
\c :TEST_DBNAME :ROLE_SUPERUSER
ALTER VIEW _timescaledb_internal._dir_rename_testview SET SCHEMA public;
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name,
direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
user_view_schema | user_view_name | partial_view_schema | partial_view_name | direct_view_schema | direct_view_name
------------------+----------------+-----------------------+-----------------------------+-----------------------+----------------------
public | mat_m1 | _timescaledb_internal | ts_internal_mat_m1view | _timescaledb_internal | _dir_mat_m1view
rename_schema | rename_test | public | ts_internal_rename_testview | public | _dir_rename_testview
(2 rows)
\c :TEST_DBNAME :ROLE_SUPERUSER
ALTER SCHEMA rename_schema RENAME TO new_name_schema;
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
@ -149,19 +170,31 @@ SELECT * FROM rename_c_aggregate;
(0 rows)
ALTER VIEW rename_schema.ts_internal_rename_testview RENAME TO partial_view;
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name,
direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
user_view_schema | user_view_name | partial_view_schema | partial_view_name
------------------+--------------------+-----------------------+------------------------
public | mat_m1 | _timescaledb_internal | ts_internal_mat_m1view
public | rename_c_aggregate | rename_schema | partial_view
user_view_schema | user_view_name | partial_view_schema | partial_view_name | direct_view_schema | direct_view_name
------------------+--------------------+-----------------------+------------------------+-----------------------+----------------------
public | mat_m1 | _timescaledb_internal | ts_internal_mat_m1view | _timescaledb_internal | _dir_mat_m1view
public | rename_c_aggregate | rename_schema | partial_view | public | _dir_rename_testview
(2 rows)
--rename direct view
ALTER VIEW _dir_rename_testview RENAME TO direct_view;
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name,
direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
user_view_schema | user_view_name | partial_view_schema | partial_view_name | direct_view_schema | direct_view_name
------------------+--------------------+-----------------------+------------------------+-----------------------+------------------
public | mat_m1 | _timescaledb_internal | ts_internal_mat_m1view | _timescaledb_internal | _dir_mat_m1view
public | rename_c_aggregate | rename_schema | partial_view | public | direct_view
(2 rows)
-- drop_chunks tests
DROP TABLE conditions CASCADE;
NOTICE: drop cascades to view _timescaledb_internal.ts_internal_mat_m1view
NOTICE: drop cascades to 2 other objects
DROP TABLE foo CASCADE;
NOTICE: drop cascades to view rename_schema.partial_view
NOTICE: drop cascades to 2 other objects
CREATE TABLE drop_chunks_table(time BIGINT, data INTEGER);
SELECT hypertable_id AS drop_chunks_table_id
FROM create_hypertable('drop_chunks_table', 'time', chunk_time_interval => 10) \gset
@ -305,7 +338,7 @@ SELECT * FROM drop_chunks_view ORDER BY 1;
-- drop chunks when the chunksize and time_bucket aren't aligned
DROP TABLE drop_chunks_table CASCADE;
NOTICE: drop cascades to view _timescaledb_internal.ts_internal_drop_chunks_viewview
NOTICE: drop cascades to 2 other objects
NOTICE: drop cascades to table _timescaledb_internal._hyper_6_4_chunk
CREATE TABLE drop_chunks_table_u(time BIGINT, data INTEGER);
SELECT hypertable_id AS drop_chunks_table_u_id

View File

@ -380,7 +380,7 @@ ALTER VIEW :"PART_VIEW_SCHEMA".:"PART_VIEW_NAME" SET(timescaledb.refresh_lag = '
ERROR: cannot alter the internal view of a continuous aggregate
\set ON_ERROR_STOP 1
DROP TABLE conditions CASCADE;
NOTICE: drop cascades to view _timescaledb_internal.ts_internal_mat_with_testview
NOTICE: drop cascades to 2 other objects
--test WITH using a hypertable with an integer time dimension
CREATE TABLE conditions (
timec SMALLINT NOT NULL,

View File

@ -1039,5 +1039,5 @@ SELECT * FROM negative_view_5 ORDER BY 1;
(4 rows)
DROP TABLE continuous_agg_negative CASCADE;
NOTICE: drop cascades to view _timescaledb_internal.ts_internal_negative_view_5view
NOTICE: drop cascades to 2 other objects
NOTICE: drop cascades to 2 other objects

View File

@ -109,8 +109,8 @@ select view_name, view_owner, refresh_lag, refresh_interval, materialization_hyp
from timescaledb_information.continuous_aggregates
where view_name::text like '%test_continuous_agg_view';
--TODO
--select view_name, viewdefinition from timescaledb_information.continuous_aggregate_settings where view_name::text like '%test_continuous_agg_view';
select view_name, view_definition from timescaledb_information.continuous_aggregates
where view_name::text like '%test_continuous_agg_view';
select view_name, completed_threshold, invalidation_threshold, job_status, last_run_duration from timescaledb_information.continuous_aggregate_stats where view_name::text like '%test_continuous_agg_view';

View File

@ -298,6 +298,10 @@ group by time_bucket('1week', timec)
having min(location) >= 'NYC' and avg(temperature) > 20 and avg(lowp) > 10
order by time_bucket('1week', timec), min(location);
--check view defintion in information views
select view_name, view_definition from timescaledb_information.continuous_aggregates
where view_name::text like 'mat_m1';
--TEST6 -- select from internal view
\c :TEST_DBNAME :ROLE_SUPERUSER
@ -363,7 +367,9 @@ SELECT
SELECT h.schema_name AS "MAT_SCHEMA_NAME",
h.table_name AS "MAT_TABLE_NAME",
partial_view_name as "PART_VIEW_NAME",
partial_view_schema as "PART_VIEW_SCHEMA"
partial_view_schema as "PART_VIEW_SCHEMA",
direct_view_name as "DIR_VIEW_NAME",
direct_view_schema as "DIR_VIEW_SCHEMA"
FROM _timescaledb_catalog.continuous_agg ca
INNER JOIN _timescaledb_catalog.hypertable h ON(h.id = ca.mat_hypertable_id)
WHERE user_view_name = 'mat_test'
@ -371,6 +377,7 @@ WHERE user_view_name = 'mat_test'
DROP TABLE :"MAT_SCHEMA_NAME".:"MAT_TABLE_NAME";
DROP VIEW :"PART_VIEW_SCHEMA".:"PART_VIEW_NAME";
DROP VIEW :"DIR_VIEW_SCHEMA".:"DIR_VIEW_NAME";
DROP VIEW mat_test;
\set ON_ERROR_STOP 1
@ -379,9 +386,10 @@ SELECT count(*)
FROM _timescaledb_catalog.continuous_agg ca
WHERE user_view_name = 'mat_test';
--mat table, user_view, and partial view all there
--mat table, user_view, direct view and partial view all there
select count(*) from pg_class where relname = :'PART_VIEW_NAME';
select count(*) from pg_class where relname = :'MAT_TABLE_NAME';
select count(*) from pg_class where relname = :'DIR_VIEW_NAME';
select count(*) from pg_class where relname = 'mat_test';
DROP VIEW mat_test CASCADE;
@ -391,9 +399,10 @@ SELECT count(*)
FROM _timescaledb_catalog.continuous_agg ca
WHERE user_view_name = 'mat_test';
--mat table, user_view, and partial view all gone
--mat table, user_view, direct view and partial view all gone
select count(*) from pg_class where relname = :'PART_VIEW_NAME';
select count(*) from pg_class where relname = :'MAT_TABLE_NAME';
select count(*) from pg_class where relname = :'DIR_VIEW_NAME';
select count(*) from pg_class where relname = 'mat_test';

View File

@ -65,6 +65,17 @@ ALTER VIEW _timescaledb_internal.ts_internal_rename_testview SET SCHEMA public;
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name
FROM _timescaledb_catalog.continuous_agg;
--alter direct view schema
SELECT user_view_schema, user_view_name, direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
\c :TEST_DBNAME :ROLE_SUPERUSER
ALTER VIEW _timescaledb_internal._dir_rename_testview SET SCHEMA public;
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name,
direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
\c :TEST_DBNAME :ROLE_SUPERUSER
ALTER SCHEMA rename_schema RENAME TO new_name_schema;
@ -111,7 +122,14 @@ SELECT * FROM rename_c_aggregate;
ALTER VIEW rename_schema.ts_internal_rename_testview RENAME TO partial_view;
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name,
direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
--rename direct view
ALTER VIEW _dir_rename_testview RENAME TO direct_view;
SELECT user_view_schema, user_view_name, partial_view_schema, partial_view_name,
direct_view_schema, direct_view_name
FROM _timescaledb_catalog.continuous_agg;
-- drop_chunks tests