Given the line protocol:
test,thing=a,version=x some_field=1 1699661173
test,thing=a,version=x some_field=2 1699661174
test,thing=a,version=y some_field=2 1699661175
test,thing=b,version=y some_field=2 1699661176
test,thing=b,version=y some_field=2 1699661177
Is it possible to return the unique combinations of “version” AND “thing” using InfluxQL?
I can do this in Flux using:
from(bucket: "testing")
|> range(start: -1d )
|> filter(fn: (r) => r["_measurement"] == "test")
|> filter(fn: (r) => r["_field"] == "some_field")
|> group(columns:["thing"])
|> unique(column:"version")
returns the below; the rows with the same thing and version are removed:
,result,table,_start,_stop,_time,_value,_field,_measurement,thing,version
,_result,0,2023-11-10T00:23:10.268015781Z,2023-11-11T00:23:10.268015781Z,2023-11-11T00:06:13Z,1,some_field,test,a,x
,_result,0,2023-11-10T00:23:10.268015781Z,2023-11-11T00:23:10.268015781Z,2023-11-11T00:06:15Z,2,some_field,test,a,y
,_result,1,2023-11-10T00:23:10.268015781Z,2023-11-11T00:23:10.268015781Z,2023-11-11T00:06:16Z,2,some_field,test,b,y
I can’t seem to find an equivalent in InfluxQL using various combinations of DISTINCT, nested queries etc. Is there a way?
I can get all of the data and using pandas, get an equivalent result. But the problem is that there might by a significant amount of data - much of it redundant (same tag set) - so for performance reasons, I’m trying where possible to do the “heavy lifting” inside of Influx.
The answer to why I don’t I just use flux is a long one…
Thanks,
Tom