I am currently working on a project that stores IOT information as JSON in Postgresql, and I decided to use timescale extension because I require some functionality like interpolation for when a component goes down or so for an hour or so. I am trying to divide my data across 1 hour buckets and and the field value is one of the keys in the JSON field but to no avail. Can you please help I am getting very unpredictable time buckets when I use the time_bucket_gapfill function Here is my query
SELECT
time_bucket_gapfill(
'1 hour ', module_timestamp,
start => '2020-04-20 15:00',
finish => '2020-04-21 17:00') AS hour,
interpolate(CAST(component_data->'common'->'bat' AS INT)) AS avg_val
FROM main_componentmessage order by hour;
and here are is the result I am getting
hour | avg_val
------------------------+---------
2020-03-10 09:00:00+00 | 30
2020-04-20 17:00:00+00 |
2020-04-20 18:00:00+00 | 50
I do not understand why the start parameter did not act as an upper limit and I do not understand why the middle row did not interpolate to 40