Skip to content

Commit

Permalink
Version 5
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziomello committed Dec 16, 2024
1 parent 4e6979d commit 56f53be
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 42 deletions.
1 change: 0 additions & 1 deletion tsl/src/continuous_aggs/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,6 @@ tsl_cagg_get_bucket_function_info(Oid view_oid)
Assert(query->commandType == CMD_SELECT);

ContinuousAggsBucketFunction *bf = palloc0(sizeof(ContinuousAggsBucketFunction));
TIMESTAMP_NOBEGIN(bf->bucket_time_origin);

ListCell *l;
foreach (l, query->groupClause)
Expand Down
5 changes: 2 additions & 3 deletions tsl/src/continuous_aggs/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,23 +596,22 @@ continuous_agg_migrate_to_time_bucket(PG_FUNCTION_ARGS)
/* Update the time_bucket_fuction */
cagg->bucket_function->bucket_function = new_bucket_function;
bool origin_added_during_migration = false;
TimestampTz bucket_time_origin_to_replace = cagg->bucket_function->bucket_time_origin;

/* Set new origin if not already present in the function definition. This is needed since
* time_bucket and time_bucket_ng use different origin default values.
*/
if (cagg->bucket_function->bucket_time_based &&
TIMESTAMP_NOT_FINITE(cagg->bucket_function->bucket_time_origin))
{
bucket_time_origin_to_replace = continuous_agg_get_default_origin(new_bucket_function);
cagg->bucket_function->bucket_time_origin = continuous_agg_get_default_origin(new_bucket_function);;
origin_added_during_migration = true;
}

/* Modify the CAgg view definition */
continuous_agg_replace_function(cagg,
old_bucket_function,
origin_added_during_migration,
bucket_time_origin_to_replace,
cagg->bucket_function->bucket_time_origin,
need_parameter_order_change);

CommandCounterIncrement();
Expand Down
4 changes: 2 additions & 2 deletions tsl/test/expected/cagg_query-14.out
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate
SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin';
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t
public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
(1 row)

DROP MATERIALIZED VIEW cagg_4_hours_date_origin;
Expand All @@ -1056,7 +1056,7 @@ psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate
SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2';
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Fri Dec 31 16:00:00 1999 PST | | | t
public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
(1 row)

DROP MATERIALIZED VIEW cagg_4_hours_date_origin2;
Expand Down
12 changes: 6 additions & 6 deletions tsl/test/expected/cagg_query-15.out
Original file line number Diff line number Diff line change
Expand Up @@ -1040,9 +1040,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_origin
GROUP BY 1 ORDER BY 1;
psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin"
SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin';
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+--------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
(1 row)

DROP MATERIALIZED VIEW cagg_4_hours_date_origin;
Expand All @@ -1054,9 +1054,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2
GROUP BY 1 ORDER BY 1;
psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2"
SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2';
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+---------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin2 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
(1 row)

DROP MATERIALIZED VIEW cagg_4_hours_date_origin2;
Expand Down
12 changes: 6 additions & 6 deletions tsl/test/expected/cagg_query-16.out
Original file line number Diff line number Diff line change
Expand Up @@ -1034,9 +1034,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_origin
GROUP BY 1 ORDER BY 1;
psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin"
SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin';
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+--------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
(1 row)

DROP MATERIALIZED VIEW cagg_4_hours_date_origin;
Expand All @@ -1048,9 +1048,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2
GROUP BY 1 ORDER BY 1;
psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2"
SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2';
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+---------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin2 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
(1 row)

DROP MATERIALIZED VIEW cagg_4_hours_date_origin2;
Expand Down
12 changes: 6 additions & 6 deletions tsl/test/expected/cagg_query-17.out
Original file line number Diff line number Diff line change
Expand Up @@ -1034,9 +1034,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_origin
GROUP BY 1 ORDER BY 1;
psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin"
SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin';
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+--------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
(1 row)

DROP MATERIALIZED VIEW cagg_4_hours_date_origin;
Expand All @@ -1048,9 +1048,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2
GROUP BY 1 ORDER BY 1;
psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2"
SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2';
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+---------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin2 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
(1 row)

DROP MATERIALIZED VIEW cagg_4_hours_date_origin2;
Expand Down
12 changes: 6 additions & 6 deletions tsl/test/expected/cagg_query_using_merge-15.out
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_origin
GROUP BY 1 ORDER BY 1;
psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin"
SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin';
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+--------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
(1 row)

DROP MATERIALIZED VIEW cagg_4_hours_date_origin;
Expand All @@ -1056,9 +1056,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2
GROUP BY 1 ORDER BY 1;
psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2"
SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2';
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+---------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin2 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
(1 row)

DROP MATERIALIZED VIEW cagg_4_hours_date_origin2;
Expand Down
12 changes: 6 additions & 6 deletions tsl/test/expected/cagg_query_using_merge-16.out
Original file line number Diff line number Diff line change
Expand Up @@ -1036,9 +1036,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_origin
GROUP BY 1 ORDER BY 1;
psql:include/cagg_query_common.sql:484: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin"
SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin';
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+--------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+--------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
(1 row)

DROP MATERIALIZED VIEW cagg_4_hours_date_origin;
Expand All @@ -1050,9 +1050,9 @@ CREATE MATERIALIZED VIEW cagg_4_hours_date_origin2
GROUP BY 1 ORDER BY 1;
psql:include/cagg_query_common.sql:492: NOTICE: refreshing continuous aggregate "cagg_4_hours_date_origin2"
SELECT * FROM caggs_info WHERE user_view_name = 'cagg_4_hours_date_origin2';
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+---------------------------+--------------------------------------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin2 | public.time_bucket(interval,pg_catalog.date,pg_catalog.date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
user_view_schema | user_view_name | bucket_func | bucket_width | bucket_origin | bucket_offset | bucket_timezone | bucket_fixed_width
------------------+---------------------------+---------------------------------+--------------+------------------------------+---------------+-----------------+--------------------
public | cagg_4_hours_date_origin2 | time_bucket(interval,date,date) | @ 4 days | Sat Jan 01 00:00:00 2000 PST | | | t
(1 row)

DROP MATERIALIZED VIEW cagg_4_hours_date_origin2;
Expand Down
Loading

0 comments on commit 56f53be

Please sign in to comment.