forked from timescale/timescaledb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix partial view definition on CAggs
When creating a CAgg using a column on the projection that is not part of the `GROUP BY` clause but is functionally dependent of the primary key of the referenced table is leading to a problem in dump/restore because the wrong dependencies created changing the order and way dump is generated. Fixed it by copying the `Query` data structure of the `direct view` and changing the necessary properties instead of creating it from scratch.
- Loading branch information
1 parent
d2b0213
commit bdfac29
Showing
5 changed files
with
47 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- This file and its contents are licensed under the Apache License 2.0. | ||
-- Please see the included NOTICE for copyright information and | ||
-- LICENSE-APACHE for a copy of the license. | ||
|
||
CREATE SCHEMA cagg_join; | ||
CREATE TABLE cagg_join.sensor( | ||
id SERIAL PRIMARY KEY, | ||
name TEXT, | ||
enabled BOOLEAN | ||
); | ||
|
||
CREATE TABLE cagg_join.measurement( | ||
sensor_id INTEGER REFERENCES cagg_join.sensor(id), | ||
observed TIMESTAMPTZ, | ||
value FLOAT | ||
); | ||
|
||
SELECT create_hypertable('cagg_join.measurement', 'observed'); | ||
|
||
CREATE MATERIALIZED VIEW cagg_join.measurement_daily | ||
WITH (timescaledb.continuous) AS | ||
-- Column s.name is functionally dependent on s.id (primary key) | ||
SELECT s.id, s.name, time_bucket(interval '1 day', observed) as bucket, avg(value), min(value), max(value) | ||
FROM cagg_join.sensor s | ||
JOIN cagg_join.measurement m on (s.id = m.sensor_id) | ||
GROUP BY s.id, bucket; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters