The data I need is there in the headers of the table (i.e. #datatype)
The data is also written as column headings (i.e. “_value (boolean)”, “_value (number)” and “_value (string)”
So alll I need is a final command that maps each _value into its type (i.e. bool, long, double, string)
I’m needing something like
|> map(fn: ( r ) => ({ r with _type: type(v: r._value) }))
or
|> map(fn: ( r ) => ({ r with _type: r["#datatype]) }))
Hello @asmith,
I’m not sure how you can do that with Flux. What is your end goal/What are you ultimately trying to achieve? There might be another solution. Can you please provide me with some more context?
Also, there are operations that I may want to do that differ whether I’m displaying boolean or float. E.g.an aggregation that averages the value for a window if it’s a float or long but chooses the max in the window period if it’s a boolean
@Anaisdg
Just thought I’d re-invigorate this question about #types
It’s come up again!
So basically I have a query that reads all data for a particular IOT device. This brings back a mix of booleans, floats, strings and ints.
Now to simplify the charting, I want to be able to convert all booleans to ints. But of course I don’t want to use toInt because then I’d loose the floats. So what I want to do is have a map() that looks at the #type of the data. IF it’s a boolean, it calculates toInt(), If it’s an int or a float or a string then it copies the original value.
InfluxDB knows this info because the type of each data point is written at the top of the table. But the variable doesn’t seem to be accessible from flux
Can you help flag this missing feature internally @Anaisdg ? Now that 2.x has been live for a while these types of gaps that have been open for a long time ought to be prioritized soon.,eg for next release or the one after etc.