I got a question regarding Flux’s aggregateWindow() function. As described in the docs, it’s default column to operate on is _value and can be changed to a particular other column.
The schema of the measurement I want to query consists of different data types, so also String data fields are included. On strings the aggregateWindow() function does not work and makes no sense, of course. Hence, my query crashes if I call aggregateWindow() once at the end of the query. Is there a way to add an aggregateWindow() or something similar to each filter()-statement in my query, so that only the columns are aggregated that I explicitly want them to? If not, is there a way to achieve that somehow else?
Thank you in advance.
aggregateWindow() can work with string values, but it depends on the
fn you use. The
fn parameter supports both aggregate functions and selector functions. To aggregate fields with string values, you need to use a selector function.
Functionality that is missing from Flux, but is planned, is the ability to 1) get the datatype of a column mid-query and 2) filter data based on the datatype of a specific column. This would allow you to conditionally apply an aggregate or selector function based on the data type of the
_value column in each table. See influxdata/flux#2159 for more information.
In the mean time, you’ll have to filter out the fields with string values and aggregate them separately, but you have to know exactly what those fields are.