Assuming a very simple table with:
One column ts
(of type nanotimestamp),
One column value
(of type double).
I want to sample the value
once every hour.
The standard syntax should be like this:
ts = 2024.03.26T09:30:00.005 2024.03.26T09:31:00.123 2024.03.26T10:30:00.105
val = 1.5 2.5 2.0
t = table(ts, val)
select last(val)
from t
group by bar(ts, 1s)
order by bar_ts
output:
bar_ts last_val
------------------- --------
2024.03.26T09:30:00 1.5
2024.03.26T09:31:00 2.5
2024.03.26T10:30:00 2
However, the results obtained this way are not precisely 3600 records since the data points are not evenly distributed along the timeline. Sometimes, there is not a single value for one or two seconds, resulting in missing time intervals, such as the 09:32:00 to 10:29:00 gap in the example above.
Is there a way to accurately generate samples representing the true ‘last seen value’?