Patse
June 30, 2021, 7:31am
1
Hey,
i have a Table with 20 columns and every now and the there is a gap that needs to be filled with the previous value. At the moment i am using the fill function 20 times to fill every column. The Problem is that the Query Perfomance is to slow and i want to optimize it.
My Query looks like this:
from(bucket: “MyBucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) =>
r._measurement == “MyMeasurement” and
r.short == “M1” or
r.short == “M2” or
r.short == “M3” or
r.short == “M4” or
(and so on up to M20)
)
|>keep(columns:["_time",“short”,"_field","_value"])
|> pivot(
rowKey:["_time"],
columnKey: ["short","_field"],
valueColumn: "_value"
)
|>fill(column:“M1”,usePrevious:true)
|>fill(column:“M2”,usePrevious:true)
|>fill(column:“M3”,usePrevious:true)
|>fill(column:“M4”,usePrevious:true)
(And so on up to M20)
Is there a way that i can use the fill() function or something similiar only once?
Hello @Patse ,
I’m sorry to inform you that this is currently possible. However, if you’re interested in seeing this added to Flux, please comment on the issue below:
opened 07:21PM - 30 Jul 20 UTC
enhancement
community
team/query
This was prompted by this community issue: https://community.influxdata.com/t/ho… w-can-i-pass-null-as-literal/14174/5
I think it would make it easier to use join or pivot if fill was able to operate on multiple columns. At the current moment, you have to write a separate fill function for each column you want filled. It might be useful to allow fill to operate on multiple columns or to accept a schema such as these:
```
|> fill(columns: ["bookie1", "bookie2"])
|> fill(fn: (col) => col.label =~ /bookie/)
```
This would prevent the need to write a new fill function for each column that you want to fill.
Patse
July 1, 2021, 6:35am
3
Hey thank you for your help.
To bad it doesn’t work.