-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass join related structs to the cagg rte
In case of joins in the continuous aggregates, pass the required structs to the new rte created. These values are required by the planner to finally query the materialized view. Fixes #5433
- Loading branch information
1 parent
72c0f5b
commit a243b75
Showing
18 changed files
with
801 additions
and
25 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
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,9 @@ | ||
-- 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. | ||
|
||
DROP MATERIALIZED VIEW cagg_joins_upgrade_test_with_realtime; | ||
DROP MATERIALIZED VIEW cagg_joins_upgrade_test; | ||
|
||
DROP TABLE ht_cagg_joins CASCADE; | ||
DROP TABLE nt_cagg_joins CASCADE; |
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,6 @@ | ||
-- 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. | ||
|
||
\ir cleanup.v7.sql | ||
\ir cleanup.continuous_aggs.v9.sql |
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,7 @@ | ||
-- 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. | ||
|
||
SELECT * FROM cagg_joins_upgrade_test_with_realtime ORDER BY bucket; | ||
SELECT * FROM cagg_joins_upgrade_test ORDER BY 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- 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. | ||
|
||
--\ir post.v8.sql |
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,53 @@ | ||
-- 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 TABLE ht_cagg_joins( | ||
day DATE NOT NULL, | ||
city text NOT NULL, | ||
temperature INT NOT NULL, | ||
device_id int NOT NULL); | ||
SELECT create_hypertable( | ||
'ht_cagg_joins', 'day', | ||
chunk_time_interval => INTERVAL '1 day' | ||
); | ||
INSERT INTO ht_cagg_joins (day, city, temperature, device_id) VALUES | ||
('2021-06-14', 'Moscow', 26,1), | ||
('2021-06-15', 'Moscow', 22,2), | ||
('2021-06-16', 'Moscow', 24,3), | ||
('2021-06-17', 'Moscow', 24,4), | ||
('2021-06-18', 'Moscow', 27,4), | ||
('2021-06-19', 'Moscow', 28,4), | ||
('2021-06-20', 'Moscow', 30,1), | ||
('2021-06-21', 'Moscow', 31,1), | ||
('2021-06-22', 'Moscow', 34,1), | ||
('2021-06-23', 'Moscow', 34,2), | ||
('2021-06-24', 'Moscow', 34,2), | ||
('2021-06-25', 'Moscow', 32,3), | ||
('2021-06-26', 'Moscow', 32,3), | ||
('2021-06-27', 'Moscow', 31,3); | ||
|
||
CREATE TABLE nt_cagg_joins ( device_id int not null, name text, location text); | ||
INSERT INTO nt_cagg_joins values (1, 'thermo_1', 'Moscow'), (2, 'thermo_2', 'Berlin'),(3, 'thermo_3', 'London'),(4, 'thermo_4', 'Stockholm'); | ||
|
||
--Create a cagg with join between a hypertable and a normal table | ||
-- with equality condition on inner join type and realtime aggregation enabled | ||
CREATE MATERIALIZED VIEW cagg_joins_upgrade_test_with_realtime | ||
WITH (timescaledb.continuous, timescaledb.materialized_only = FALSE) AS | ||
SELECT time_bucket(INTERVAL '1 day', day) AS bucket, | ||
AVG(temperature), | ||
name | ||
FROM ht_cagg_joins JOIN nt_cagg_joins | ||
ON ht_cagg_joins.device_id = nt_cagg_joins.device_id | ||
GROUP BY 1,3; | ||
|
||
--Create a cagg with join between a hypertable and a normal table | ||
-- with equality condition on inner join type and realtime aggregation disabled | ||
CREATE MATERIALIZED VIEW cagg_joins_upgrade_test | ||
WITH (timescaledb.continuous, timescaledb.materialized_only = TRUE) AS | ||
SELECT time_bucket(INTERVAL '1 day', day) AS bucket, | ||
AVG(temperature), | ||
name | ||
FROM nt_cagg_joins JOIN ht_cagg_joins | ||
ON ht_cagg_joins.device_id = nt_cagg_joins.device_id | ||
GROUP BY 1,3; |
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,6 @@ | ||
-- 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. | ||
|
||
\ir setup.v8.sql | ||
\ir setup.continuous_aggs.v9.sql |
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
Oops, something went wrong.