One thing to watch for, is SQL queries will return wide rather than long tables.
So we'd need a way to identify which columns are fields and which should be considered tags.
The best route is probably to allow that to be specified in YAML - that'd allow jobs to convert fields to tags if needed.
Something like
measurement: sensors
query_type: sql
sql_fields:
- pressure
- temperature
sql_tags:
- host
- unit
Which'd then be translated into something like
SELECT
pressure,
temperature,
host,
unit
FROM sensors
I need to check, but we should be able to have the query figure out the time window for us
SELECT
date_bin(interval '15 min', time, timestamp '1970-01-01T00:00:00Z') as timebin,
pressure,
temperature,
host,
unit
FROM sensors
What we won't be able to do is have the results returned in individual Flux-esque tables.
We can't group by timebin in the query because then we have to use aggregate functions on anything that is'nt part of the group key (pushing the processing overhead onto IOx - as noted in #22 that's probably ok really, but not in keeping with the point of this project).
So, we'd need some processing logic which handles the physical grouping on our side.
There are probably a couple of ways to go at that
Just iterate over, building per-time value lists
Iterate through each, applying the aggregates as we go
One is (obviously) more efficient, but will need significant changes to existing logic (assuming we want to keep it DRY).
Activity
16-Feb-23 13:01
assigned to @btasker
16-Feb-23 13:33
Thinking this through then:
One thing to watch for, is SQL queries will return wide rather than long tables.
So we'd need a way to identify which columns are fields and which should be considered tags.
The best route is probably to allow that to be specified in YAML - that'd allow jobs to convert fields to tags if needed.
Something like
Which'd then be translated into something like
I need to check, but we should be able to have the query figure out the time window for us
What we won't be able to do is have the results returned in individual Flux-esque tables.
We can't group by
timebin
in the query because then we have to use aggregate functions on anything that is'nt part of the group key (pushing the processing overhead onto IOx - as noted in #22 that's probably ok really, but not in keeping with the point of this project).So, we'd need some processing logic which handles the physical grouping on our side.
There are probably a couple of ways to go at that
One is (obviously) more efficient, but will need significant changes to existing logic (assuming we want to keep it DRY).
05-May-23 07:59
mentioned in issue #26