Weird error returned when using date.sub

I’m receiving the following error when I try to map the date.sub function to the first records in a table. Any advise would be appreciated.

import "date"

data = from(bucket: "xxxxxxxxx")
 |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
 |> filter(fn: (r) => r["_measurement"] == "xxxxxxxxx")



first = data    
          |> first(column: "_time")
          |> map(fn: (r) => ({r with diff: date.sub(d:7d,from:r._time)}))
          |> yield()

this returns:

error @11:44-11:48: record is missing label sub

Hello @blharvey,
What version of InfluxDB are you using? You might need to upgrade.
That query works for me in Cloud.

date.sub() was introduced in Flux 0.162.0, there is no OSS release yet that contains this Flux version.

experimental.subDuration() comes to the rescue until then.

Thanks for the info. I’ll use subDuration going forward.