Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter materialized hypertables in view #2384

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion sql/views.sql
Expand Up @@ -25,6 +25,8 @@ CREATE OR REPLACE VIEW timescaledb_information.hypertables AS
INNER JOIN pg_tables t
ON ht.table_name=t.tablename
AND ht.schema_name=t.schemaname
LEFT OUTER JOIN _timescaledb_catalog.continuous_agg ca
ON ca.mat_hypertable_id=ht.id
LEFT OUTER JOIN (
SELECT hypertable_id,
array_agg(tablespace_name ORDER BY id) as tablespace_list
Expand All @@ -38,7 +40,7 @@ CREATE OR REPLACE VIEW timescaledb_information.hypertables AS
GROUP BY hypertable_id) dn
ON ht.id = dn.hypertable_id
WHERE ht.compressed is false --> no internal compression tables
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not direct part of PR, but can you fix capitalisation of the keywords, since it is related and was overlooked in the correct PR review?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue is prevalent throughout the SQL code. I suggest we adopt a formatter and make sure this is fixed in all places.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is next to your line, so it was an obvious and easy fix, taking in account that you were fixing commit message and rebase in any case. Postponing is also fine (it just looked to me weird to have two lines next to each other in different style).

;
AND ca.mat_hypertable_id IS NULL;

CREATE OR REPLACE VIEW timescaledb_information.license AS
SELECT _timescaledb_internal.license_edition() as edition,
Expand Down
10 changes: 10 additions & 0 deletions tsl/test/expected/continuous_aggs.out
Expand Up @@ -137,6 +137,16 @@ FROM _timescaledb_catalog.continuous_agg ca
INNER JOIN _timescaledb_catalog.hypertable h ON(h.id = ca.mat_hypertable_id)
WHERE user_view_name = 'mat_m1'
\gset
-- Materialized hypertable for mat_m1 should not be visible in the
-- hypertables view:
SELECT table_schema, table_name
FROM timescaledb_information.hypertables;
table_schema | table_name
--------------+------------
public | foo
public | conditions
(2 rows)

SET ROLE :ROLE_SUPERUSER;
insert into :"MAT_SCHEMA_NAME".:"MAT_TABLE_NAME"
select
Expand Down
5 changes: 5 additions & 0 deletions tsl/test/sql/continuous_aggs.sql
Expand Up @@ -114,6 +114,11 @@ INNER JOIN _timescaledb_catalog.hypertable h ON(h.id = ca.mat_hypertable_id)
WHERE user_view_name = 'mat_m1'
\gset

-- Materialized hypertable for mat_m1 should not be visible in the
-- hypertables view:
SELECT table_schema, table_name
FROM timescaledb_information.hypertables;

SET ROLE :ROLE_SUPERUSER;
insert into :"MAT_SCHEMA_NAME".:"MAT_TABLE_NAME"
select
Expand Down