I am building a materialized view using continuous aggregate while also passing origin
parameter. Here is the command I use for time-bucketing:
time_bucket('7 day', time, TIMESTAMPTZ '2022-01-03') AS date
. I use this command exactly as I found in Timescaledb docs (here: https://docs.timescale.com/api/latest/hyperfunctions/time_bucket/#sample-usage)
However, I get the following error:
ERROR: continuous aggregate view must include a valid time bucket function
My time
column in the hypertable is with timezone. I tried the origin parameter with a TIMESTAMP
, instead of TIMESTAMPTZ
, still the same error.
My continuous aggregate works fine if I exclude the origin parameter. However, I need the origin parameter. It would be great if I can get some help here. Thanks!
Further update:
For example,
the following command works:
CREATE MATERIALIZED VIEW one_week_candle
WITH (timescaledb.continuous) AS
SELECT symbol,
time_bucket('7 day', time) AS date,
FIRST(open, time) as open,
MAX(high) as high,
MIN(low) as low,
LAST(close, time) as close
FROM stockdata
GROUP BY symbol, date;
But the following gives me error:
CREATE MATERIALIZED VIEW one_week_candle
WITH (timescaledb.continuous) AS
SELECT symbol,
time_bucket('7 day', time, TIMESTAMPTZ '2022-01-03') AS date,
FIRST(open, time) as open,
MAX(high) as high,
MIN(low) as low,
LAST(close, time) as close
FROM stockdata
GROUP BY symbol, date;