Are there plans for a partition(fn: (r, p) => true) style function

I have a query using stateCount where I would really like to group the output based upon a change of state. There does not seem to be anything available that would let me do this.

It occurs to me that if you added a new function (partition say) that accepted two parameters, current and previous record, then returned true if they belong in the same group, you could partition data into groups using arbitrary logic. Obviously the first record in a table would always be in a new group so you only call the function for second and subsequent records in a table. Something like this:

|> stateCount(fn: (r) => >= 500, column: "over")
|> partition(fn: (r, p) => r.over == p.over + 1)

Hello @davejohncole,
Welcome! Would you be willing to contribute that? I’d be happy to meet with you to help you if you need. Contributing Third Party Flux Packages: A Discord Endpoint Flux Function | InfluxData

You would have to:

  1. create a dir for your project in the contrib dir of the flux repo
  2. write the function
  3. write a test complete with sample inData and outData