timeRangeStart and timeRangeStop does not filter on renamed _time

Hi!

If I do the following query where “suite_time” is a time column

from(bucket: "example_bucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "foo")
  |> rename(columns: {_time: "measurement_time"})
  |> rename(columns: {suite_time: "_time"})
  |> keep(columns: ["_time", "_value"])

… the time range filtering seems to still apply to the “old” _time column (before renaming). Is this by design?

Hello @stefan.bie,
I’m not sure what you mean by apply the “old” _time column but the functions/transformations in flux are pipe forwarded and (well you can think of it this way in reality the functions are applied in the order to maximize the efficiency of the query) applied in order. Since you haven’t used a second range filter anywhere, you’re still just transforming the data that you collected from the first range function.

If you added a range() function after the last rename() function you wrote, it would operate on the new “_time” column or your “suite_time” data.

Hi @Anaisdg, thanks for your reply!
I tried with this:

from(bucket: "example_bucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "foo")
  |> rename(columns: {_time: "measurement_time"})
  |> map(fn: (r) => ({ r with _time: time(v: r.suite_time) }))
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> keep(columns: ["_time", "_value"])

…but range still seems to operate on the original _time. Did I do something wrong? :slight_smile:

Hello @stefan.bie,
You have to put the actual timestamps you want instead of the UI variables.

2019-08-28T22:00:00Z