# \_time column needed to get a result

**URL:** <https://community.influxdata.com/t/time-column-needed-to-get-a-result/28290>\
**Category:** Systems\
**Created:** [January 24, 2023, 9:57am UTC](https://community.influxdata.com/t/time-column-needed-to-get-a-result/28290 "2023-01-24T09:57:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ypnos](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ypnos/32/7630_2.png) [@ypnos](https://community.influxdata.com/u/ypnos)\
**Post date:** [January 24, 2023, 9:57am UTC](https://community.influxdata.com/t/time-column-needed-to-get-a-result/28290/1 "2023-01-24T09:57:06Z")

</div>

I don’t understand the observed behavior with Influx 2.6.1.

This query also returns 5 rows with column “\_value”:

```auto
from(bucket: "halfyear")
  |> range(start: -2m) // we know that data is flushed per-minute
  |> filter(fn: (r) => r["_measurement"] == "deviceStatus")
  |> keep(columns: ["_value"])
  |> yield(name: "network")

```

This query also returns 5 rows, with columns “name”, “\_value”, and “\_time”:

```auto
from(bucket: "halfyear")
  |> range(start: -2m) // we know that data is flushed per-minute
  |> filter(fn: (r) => r["_measurement"] == "deviceStatus")
  |> map(fn: (r) => ({ name: "Device", _value: if r._value == 0 then "fine" else if r._value == 1 then "warning" else "error", _time: r._time }))
  |> yield(name: "network")

```

This query returns no result!

```auto
from(bucket: "halfyear")
  |> range(start: -2m) // we know that data is flushed per-minute
  |> filter(fn: (r) => r["_measurement"] == "deviceStatus")
  |> map(fn: (r) => ({ name: "Device", _value: if r._value == 0 then "fine" else if r._value == 1 then "warning" else "error" }))
  |> yield(name: "network")

```

The only difference is that we omit \_time column because it is not needed.  
Is this a bug or expected behavior?

Thanks!

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [January 24, 2023, 8:52pm UTC](https://community.influxdata.com/t/time-column-needed-to-get-a-result/28290/2 "2023-01-24T20:52:51Z")

</div>

Hello @ypnos,  
Hmmmm wtf that makes no sense.  
Weird…can you please create an issue?

> **[GitHub - influxdata/flux: Flux is a lightweight scripting language for...](https://github.com/influxdata/flux)**
>
> Flux is a lightweight scripting language for querying databases (like InfluxDB) and working with data. It's part of InfluxDB 1.7 and 2.0, but can be run independently of those. - GitHub - influ...

Out of curiosity does this work?

```auto
from(bucket: "halfyear")
  |> range(start: -2m) // we know that data is flushed per-minute
  |> filter(fn: (r) => r["_measurement"] == "deviceStatus")
  |> map(fn: (r) => ({ name: "Device"}))
  |> map(fn: (r) => ({ _value: if r._value == 0 then "fine" else if r._value == 1 then "warning" else "error"}))
  |> map(fn: (r) => ({ _time: r._time }))
  |> yield(name: "network")

```

Maybe try commenting out each column respectively to try and find the culprit?  
Thank you

---

<div class="post-metadata">

**Author:** ![ypnos](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ypnos/32/7630_2.png) [@ypnos](https://community.influxdata.com/u/ypnos)\
**Post date:** [January 25, 2023, 3:08pm UTC](https://community.influxdata.com/t/time-column-needed-to-get-a-result/28290/3 "2023-01-25T15:08:11Z")

</div>

Only this version produces results:

```auto
from(bucket: "halfyear")
  |> range(start: -2m) // we know that data is flushed per-minute
  |> filter(fn: (r) => r["_measurement"] == "deviceStatus")
  //|> map(fn: (r) => ({ name: "Device"}))
  //|> map(fn: (r) => ({ _value: if r._value == 0 then "fine" else if r._value == 1 then "warning" else "error"}))
  |> map(fn: (r) => ({ _time: r._time }))
  |> yield(name: "network")

```

It appears like it really hates a row out of a map() without \_time. While it is o.k. to get rid of \_time via keep(). So this also works:

```auto
from(bucket: "halfyear")
  |> range(start: -2m) // we know that data is flushed per-minute
  |> filter(fn: (r) => r["_measurement"] == "deviceStatus")
  //|> map(fn: (r) => ({ name: "Device"}))
  //|> map(fn: (r) => ({ _value: if r._value == 0 then "fine" else if r._value == 1 then "warning" else "error"}))
  |> map(fn: (r) => ({ _time: r._time, name: "Device" }))
  |> keep(columns: ["name"])
  |> yield(name: "network")

```

I will file a bug report.

---

<div class="post-metadata">

**Author:** ![scott](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/scott/32/16492_2.png) [@scott](https://community.influxdata.com/u/scott)\
**Post date:** [January 25, 2023, 5:41pm UTC](https://community.influxdata.com/t/time-column-needed-to-get-a-result/28290/4 "2023-01-25T17:41:53Z")

</div>

@ypnos, Where are you running the queries? In the Data Explorer?

---

<div class="post-metadata">

**Author:** ![ypnos](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ypnos/32/7630_2.png) [@ypnos](https://community.influxdata.com/u/ypnos)\
**Post date:** [February 1, 2023, 10:59pm UTC](https://community.influxdata.com/t/time-column-needed-to-get-a-result/28290/5 "2023-02-01T22:59:36Z")

</div>

Yes.

Sorry for late reply.
