What type of bug is this?
Unexpected error
What subsystems and features are affected?
Gapfill
What happened?
time_bucket_gapfill seems to be a drop-in for time_bucket, but it has some limitations that are neither straightforward nor mentioned in the documentation.
It requires a given start/finish either as arguments (deprecated) or in where. It does not allow querying the entire table, unless I predefine the known timestamp boundaries of the table in a WHERE clause. This is also addressed in #2595 (possibly).
More importantly and less intuitively, it does not allow for references in the bucket_width argument. I have a table with known important intervals with which I would like to group the data in seconds, and I use time_bucket_gapfill(make_interval(secs => polling_interval), ts) in query time. Shouldn't that work? If not, I believe that it should be mentioned in the docs, just as using the time_bucket_gapfill as a nested expression is not possible.
TimescaleDB version affected
2.20.2
PostgreSQL version used
16.9
What operating system did you use?
Windows 11 x64, Ubuntu 24
What installation method did you use?
Docker
What platform did you run on?
On prem/Self-hosted
Relevant log output and stack trace
[22023] ERROR: invalid time_bucket_gapfill argument: bucket_width must be a simple expression
How can we reproduce the bug?
CREATE TABLE measurements
(
moment TIMESTAMPTZ NOT NULL,
resource_id INTEGER NOT NULL,
value DOUBLE PRECISION NOT NULL
);
SELECT create_hypertable('measurements', 'moment');
CREATE TABLE resources
(
id INTEGER NOT NULL,
polling_interval INTEGER NOT NULL,
CONSTRAINT resources_pkey PRIMARY KEY (id)
);
SELECT time_bucket_gapfill(MAKE_INTERVAL(secs => polling_interval), moment) AS bucket,
locf(AVG(value)) AS values,
measurements.resource_id AS parameter_id
FROM measurements
INNER JOIN resources ON measurements.resource_id = resources.id
WHERE moment BETWEEN '2025-01-01' AND '2025-02-01'
GROUP BY resource_id, bucket
ORDER BY bucket;
What type of bug is this?
Unexpected error
What subsystems and features are affected?
Gapfill
What happened?
time_bucket_gapfillseems to be a drop-in fortime_bucket, but it has some limitations that are neither straightforward nor mentioned in the documentation.It requires a given start/finish either as arguments (deprecated) or in where. It does not allow querying the entire table, unless I predefine the known timestamp boundaries of the table in a
WHEREclause. This is also addressed in #2595 (possibly).More importantly and less intuitively, it does not allow for references in the
bucket_widthargument. I have a table with known important intervals with which I would like to group the data in seconds, and I usetime_bucket_gapfill(make_interval(secs => polling_interval), ts)in query time. Shouldn't that work? If not, I believe that it should be mentioned in the docs, just as using thetime_bucket_gapfillas a nested expression is not possible.TimescaleDB version affected
2.20.2
PostgreSQL version used
16.9
What operating system did you use?
Windows 11 x64, Ubuntu 24
What installation method did you use?
Docker
What platform did you run on?
On prem/Self-hosted
Relevant log output and stack trace
How can we reproduce the bug?
CREATE TABLE measurements ( moment TIMESTAMPTZ NOT NULL, resource_id INTEGER NOT NULL, value DOUBLE PRECISION NOT NULL ); SELECT create_hypertable('measurements', 'moment'); CREATE TABLE resources ( id INTEGER NOT NULL, polling_interval INTEGER NOT NULL, CONSTRAINT resources_pkey PRIMARY KEY (id) ); SELECT time_bucket_gapfill(MAKE_INTERVAL(secs => polling_interval), moment) AS bucket, locf(AVG(value)) AS values, measurements.resource_id AS parameter_id FROM measurements INNER JOIN resources ON measurements.resource_id = resources.id WHERE moment BETWEEN '2025-01-01' AND '2025-02-01' GROUP BY resource_id, bucket ORDER BY bucket;