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

[Bug]: cagg migrate - Invalid data type timestamp without time zone for time bucket #4956

Closed
emizero opened this issue Nov 10, 2022 · 0 comments · Fixed by #4955
Closed

[Bug]: cagg migrate - Invalid data type timestamp without time zone for time bucket #4956

emizero opened this issue Nov 10, 2022 · 0 comments · Fixed by #4955
Labels

Comments

@emizero
Copy link

emizero commented Nov 10, 2022

What type of bug is this?

Unexpected error

What subsystems and features are affected?

Continuous aggregate

What happened?

Trying to migrate a continuous aggregate to finalized form.
If the time column is timestamp without time zone, attempt to migrate fails with the following error:

ERROR:  Invalid data type timestamp without time zone for time bucket
CONTEXT:  PL/pgSQL function _timescaledb_internal.cagg_migrate_execute_refresh_new_cagg(_timescaledb_catalog.continuous_agg,_timescaledb_catalog.continuous_agg_migrate_plan_step) line 17 at RAISE
SQL statement "CALL _timescaledb_internal.cagg_migrate_execute_refresh_new_cagg($1, $2)"
PL/pgSQL function _timescaledb_internal.cagg_migrate_execute_plan(_timescaledb_catalog.continuous_agg) line 31 at EXECUTE
SQL statement "CALL _timescaledb_internal.cagg_migrate_execute_plan(_cagg_data)"
PL/pgSQL function cagg_migrate(regclass,boolean,boolean) line 25 at CALL

TimescaleDB version affected

2.8.1

PostgreSQL version used

13.8

What operating system did you use?

Fedora

What installation method did you use?

Not applicable

What platform did you run on?

Managed Service for TimescaleDB (MST/Aiven)

Relevant log output and stack trace

CONTEXT: PL/pgSQL function _timescaledb_internal.cagg_migrate_execute_refresh_new_cagg(_timescaledb_catalog.continuous_agg,_timescaledb_catalog.continuous_agg_migrate_plan_step) line 17 at RAISE SQL statement "CALL _timescaledb_internal.cagg_migrate_execute_refresh_new_cagg($1, $2)" PL/pgSQL function _timescaledb_internal.cagg_migrate_execute_plan(_timescaledb_catalog.continuous_agg) line 31 at EXECUTE SQL statement "CALL _timescaledb_internal.cagg_migrate_execute_plan(_cagg_data)" PL/pgSQL function cagg_migrate(regclass,boolean,boolean) line 25 at CALL
ERROR: Invalid data type timestamp without time zone for time bucket


### How can we reproduce the bug?

```bash
--DROP TABLE test_table;
create table test_table (
    device_id bigint not null,
    reading numeric not null,
    time_ts timestamp without time zone not null
);

create index test_table_time_ts_idx on test_table(time_ts desc);

--> single node hypertable
select create_hypertable('test_table', 'time_ts', chunk_time_interval => INTERVAL '1 day');

--> (0) data

--delete from test_table;
INSERT INTO test_table (device_id, reading, time_ts)      
    SELECT
                cast(random() * 50 as int) + 1,
                generate_series(1,8467201),
                generate_series(
                    now() - INTERVAL '98 days',
                now(),
                    INTERVAL '1 second'
                );

--> (1) Create a cagg the old way - 'timescaledb.finalized = false'

--drop materialized view test_table_cagg;
CREATE MATERIALIZED VIEW test_table_cagg
WITH (timescaledb.continuous, timescaledb.finalized = false) AS
select
    time_bucket('1 hour', time_ts) as bucket,
    device_id,
    sum(reading) as sum_total,
    avg(reading) as avg_reading,
    max(reading) as max_reading
from test_table
group by device_id, bucket;

--> (2) initiate migration here

call cagg_migrate('test_table_cagg', override => true);
@emizero emizero added the bug label Nov 10, 2022
fabriziomello added a commit to fabriziomello/timescaledb that referenced this issue Nov 10, 2022
It was a leftover from the original implementation where we didn't add
tests for time dimension using `timestamp without timezone`.

Fixed it by dealing with this datatype and added regression tests.

Fixes timescale#4956
fabriziomello added a commit to fabriziomello/timescaledb that referenced this issue Nov 11, 2022
It was a leftover from the original implementation where we didn't add
tests for time dimension using `timestamp without timezone`.

Fixed it by dealing with this datatype and added regression tests.

Fixes timescale#4956
fabriziomello added a commit to fabriziomello/timescaledb that referenced this issue Nov 11, 2022
It was a leftover from the original implementation where we didn't add
tests for time dimension using `timestamp without timezone`.

Fixed it by dealing with this datatype and added regression tests.

Fixes timescale#4956
@fabriziomello fabriziomello added this to the TimescaleDB 2.8.2 milestone Nov 14, 2022
@horzsolt horzsolt modified the milestones: TimescaleDB 2.8.2, TimescaleDB 2.9 Nov 23, 2022
SachinSetiya pushed a commit that referenced this issue Nov 28, 2022
It was a leftover from the original implementation where we didn't add
tests for time dimension using `timestamp without timezone`.

Fixed it by dealing with this datatype and added regression tests.

Fixes #4956
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants