It is not clear to me from the documentation if the start and finish parameters of the time_bucket_gapfill can only be constant values. When I use time_bucket_gapfill with a time range that is dynamic, I get the following error:
Query 1 ERROR at Line 1: : ERROR: missing time_bucket_gapfill argument: could not infer start from WHERE clause
HINT: Specify start and finish as arguments or in the WHERE clause.
This is an example of what I am doing:
select *, metric.value
from
test_table,
lateral (
select
time_bucket_gapfill('1d', time) as time,
avg(value) as value
from metric
where time >= test_table.time - INTERVAL '1d' and time < NOW()
group by 1
) metric