Leo
August 1, 2024, 2:12am
1
Hello:
When i use fill(usePrevious: true) to fill null, i found a piece of data filled not from previous.
when none fill, the lastest is 26.4 at 2024-07-31 13:36:29, the rest is null
when filled, the last is 26.3 at 2024-07-31 13:41:27, which should be 26.4
so I dont know where 26.3 come from, how can i do to get the right fill
Hello @Leo ,
That is truly odd. I did see this issue:
opened 07:01PM - 01 Mar 21 UTC
closed 03:02PM - 25 Aug 21 UTC
kind/bug
team/query
The `fill()` function exists to replace null values with a given value; however,… depending on your source data and the way stuff is grouped, in some tables you may end up with the column being entirely absent, in which case `fill()` throws an error. In order to get reliable behavior, you end up having to use `map(fn: (r) => r with my_column: if exists r.my_column then r.my_column else "foo"}))`, which is _logically_ the same as `fill(column: "my_column", value: "foo")`, but works even if `my_column` happens to be absent entirely for a given table.
As an example of a real query where this becomes an issue, here is a query I wrote as part of a check that would look for (and alert on) task failures:
```flux
from(bucket: "_tasks")
|> range(start: -10m)
|> schema.fieldsAsCols()
|> group(columns: ["taskID"])
|> fill(column: "errorMessage", value: "(none)")
|> monitor.check(
crit: (r) => r.status == "failed",
messageFn: (r) => (
if r.status == "failed" then "Task '${r.name}' failed! Error message: ${r.errorMessage}"
else "Task '${r.name}' succeeded."
),
data: {...},
)
```
This looks perfectly fine at first glance, but when the check is executed, if any of the tasks had no errors in the past ten minutes, then the table for that task will have no `errorMessage` column, and then `fill()` will fail with `fill column not found: errorMessage`.
I wonder if it’s related. Maybe try commenting there?
Leo
August 5, 2024, 2:15am
3
thanks for your reply.
but the column need to be filled with previous value rather than a fixed value. Is there any better way?
Hello @Leo ,
I recommend creating an issue for that. The function should fill previous easily.
I’m not able to reproduce. Is there anyway you can limit your data to 4 lines where its not filling properly? and then export to annotated csv and share here? That way I can see the group keys and maybe try and figure out what the heck is happening.