Closed quixand closed 1 year ago
theres a hole in my graph now, lol
Could you provide me with a query containing the data in the query itself (as a subquery or CTE) so that I can reproduce the issue?
so this works ok
with cte(timestamp, sensor_name, value)
as (VALUES ('2022-10-30T01:50:00.000+01:00', 'Inlet Pipe', 1),
('2022-10-30T01:59:00.000+01:00', 'Inlet Pipe', 5),
('2022-10-30T01:10:00.000+00:00', 'Inlet Pipe', 10),
('2022-10-30T01:20:00.000+00:00', 'Barrel Lid', 15))
select * from cte
But if the timestamps are out of sequence in the DB it fails, e.g.
as (VALUES ('2022-10-30T01:50:00.000+01:00', 'Inlet Pipe', 1),
('2022-10-30T01:10:00.000+00:00', 'Inlet Pipe', 10),
('2022-10-30T01:59:00.000+01:00', 'Inlet Pipe', 5),
('2022-10-30T01:20:00.000+00:00', 'Barrel Lid', 15))
select * from cte
if you try to sort that result it also fails
order by timestamp asc;
I suspect that as sqlite doesnt have a timestamp datatype its not sorting the timestamp field correctly?
Yeah, SQLite has no date type. Unix timestamps are a great thing, though.
How about this for your CTE
with cte(timestamp, sensor_name, value)
as (VALUES ('2022-10-30T01:50:00.000+01:00', 'Inlet Pipe', 1),
('2022-10-30T01:59:00.000+01:00', 'Inlet Pipe', 5),
('2022-10-30T01:10:00.000+00:00', 'Inlet Pipe', 10),
('2022-10-30T01:20:00.000+00:00', 'Barrel Lid', 15))
select unixepoch(timestamp) AS ts, value from cte
order by 1 asc
This might be a grafana error but google is not helping. Here in the UK the clocks changed from BST to GMT at 2 am so my timestamps have rolled back an hour. e.g.
To Reproduce my grafana query is very simple
up to midnight the graph was working ok, and if I limit the query to dates before midnight or after 2 am it works ok. Any query that returns both BST and GMT timestamps generates the below error in Grafana
This query returns data ok
Interestingly, I have another graph that is not affected by this issue, different table but same timestamp format. The timestamp change occurs in the same way, the only difference is that the table has 2 columns not 3