6

Among my data, there are a couple strings in the "_value" column. This means that when I use aggregateWindow() I get this error: unsupported input type for mean aggregate: string.

I want to know how I can filter out data of type string, before passing to aggregateWindow, thus avoiding the error.

Something like this maybe:

from(bucket: "mybucket")
  |> range(start: -10m, stop: now())
  |> filter(fn: (r) => type(r["_value"]) != "string")
  |> aggregateWindow(every: 1m, fn: mean, createEmpty: false)
  |> yield(name: "mean")
Keldan Chapman
  • 665
  • 5
  • 21

1 Answers1

1

Per documentation, you can use types.isType:

Filter by value type

import "types"

data
    |> filter(fn: (r) => types.isType(v: r._value, type: "string"))

You may also want to consider types.isNumeric, or - if suitable - use regex.

OfirD
  • 9,442
  • 5
  • 47
  • 90