-
Notifications
You must be signed in to change notification settings - Fork 895
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
Refresh cagg uses min value for dimension when start_time is NULL #7546
Draft
gayyappan
wants to merge
3
commits into
timescale:main
Choose a base branch
from
gayyappan:try
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,99 @@ | ||
-- This file and its contents are licensed under the Timescale License. | ||
-- Please see the included NOTICE for copyright information and | ||
-- LICENSE-TIMESCALE for a copy of the license. | ||
-- These tests work for PG14 or greater | ||
-- Remember to coordinate any changes to functionality with the Cloud | ||
-- Native Storage team. Tests for the following API: | ||
-- * cagg refresh with GUC enable_tiered_reads | ||
\set EXPLAIN 'EXPLAIN (COSTS OFF)' | ||
--SETUP for OSM chunk -- | ||
--need superuser access to create foreign data server | ||
\c :TEST_DBNAME :ROLE_SUPERUSER | ||
CREATE DATABASE postgres_fdw_db; | ||
GRANT ALL PRIVILEGES ON DATABASE postgres_fdw_db TO :ROLE_4; | ||
\c postgres_fdw_db :ROLE_4 | ||
CREATE TABLE fdw_table( timec timestamptz NOT NULL , acq_id bigint, value bigint); | ||
INSERT INTO fdw_table VALUES( '2020-01-01 01:00', 100, 1000); | ||
--create foreign server and user mappings as superuser | ||
\c :TEST_DBNAME :ROLE_SUPERUSER | ||
SELECT current_setting('port') as "PORTNO" \gset | ||
CREATE EXTENSION postgres_fdw; | ||
CREATE SERVER s3_server FOREIGN DATA WRAPPER postgres_fdw | ||
OPTIONS ( host 'localhost', dbname 'postgres_fdw_db', port :'PORTNO'); | ||
GRANT USAGE ON FOREIGN SERVER s3_server TO :ROLE_4; | ||
CREATE USER MAPPING FOR :ROLE_4 SERVER s3_server | ||
OPTIONS ( user :'ROLE_4' , password :'ROLE_4_PASS'); | ||
ALTER USER MAPPING FOR :ROLE_4 SERVER s3_server | ||
OPTIONS (ADD password_required 'false'); | ||
\c :TEST_DBNAME :ROLE_4; | ||
-- this is a stand-in for the OSM table | ||
CREATE FOREIGN TABLE child_fdw_table | ||
(timec timestamptz NOT NULL, acq_id bigint, value bigint) | ||
SERVER s3_server OPTIONS ( schema_name 'public', table_name 'fdw_table'); | ||
--now attach foreign table as a chunk of the hypertable. | ||
CREATE TABLE ht_try(timec timestamptz NOT NULL, acq_id bigint, value bigint); | ||
SELECT create_hypertable('ht_try', 'timec', chunk_time_interval => interval '1 day'); | ||
create_hypertable | ||
--------------------- | ||
(1,public,ht_try,t) | ||
(1 row) | ||
|
||
INSERT INTO ht_try VALUES ('2022-05-05 01:00', 222, 222); | ||
SELECT * FROM child_fdw_table; | ||
timec | acq_id | value | ||
------------------------------+--------+------- | ||
Wed Jan 01 01:00:00 2020 PST | 100 | 1000 | ||
(1 row) | ||
|
||
SELECT _timescaledb_functions.attach_osm_table_chunk('ht_try', 'child_fdw_table'); | ||
attach_osm_table_chunk | ||
------------------------ | ||
t | ||
(1 row) | ||
|
||
-- must also update the range since the created chunk contains data | ||
SELECT _timescaledb_functions.hypertable_osm_range_update('ht_try', '2020-01-01'::timestamptz, '2020-01-02'); | ||
hypertable_osm_range_update | ||
----------------------------- | ||
f | ||
(1 row) | ||
|
||
set timescaledb.enable_tiered_reads = true; | ||
SELECT * from ht_try ORDER BY 1; | ||
timec | acq_id | value | ||
------------------------------+--------+------- | ||
Wed Jan 01 01:00:00 2020 PST | 100 | 1000 | ||
Thu May 05 01:00:00 2022 PDT | 222 | 222 | ||
(2 rows) | ||
|
||
--disable tiered reads -- | ||
--set timescaledb.enable_tiered_reads = false; | ||
SELECT * from ht_try ORDER BY 1; | ||
timec | acq_id | value | ||
------------------------------+--------+------- | ||
Wed Jan 01 01:00:00 2020 PST | 100 | 1000 | ||
Thu May 05 01:00:00 2022 PDT | 222 | 222 | ||
(2 rows) | ||
|
||
--TEST cagg creation | ||
CREATE MATERIALIZED VIEW cagg_ht_osm WITH (timescaledb.continuous, timescaledb.materialized_only = true) | ||
AS | ||
SELECT time_bucket('7 days'::interval, timec), count(*) | ||
FROM ht_try | ||
GROUP BY 1; | ||
NOTICE: HERE refrech window INPUT IS (-210866803200000000 9223372036854775807) (start_is_null 1) | ||
NOTICE: HERE refrech window (-210866803200000000 9223372036854775807) | ||
NOTICE: refreshing continuous aggregate "cagg_ht_osm" | ||
SELECT * FROM cagg_ht_osm ORDER BY 1; | ||
time_bucket | count | ||
------------------------------+------- | ||
Sun Dec 29 16:00:00 2019 PST | 1 | ||
Sun May 01 17:00:00 2022 PDT | 1 | ||
(2 rows) | ||
|
||
SELECT * FROM | ||
_timescaledb_catalog.continuous_aggs_hypertable_invalidation_log ORDER BY 1; | ||
hypertable_id | lowest_modified_value | greatest_modified_value | ||
---------------+-----------------------+------------------------- | ||
(0 rows) | ||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does a full table scan of the entire hypertable. With a hypertable that is big, this is going to be a significant problem, especially if tiering is involved.