influxdata / influxdata/kapacitor
Can not use lambda expression in window() node
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
I have two similar streams, where the second stream just accumulates and emits data for two periods of data insertion. And instead of hard coding that extended period duration, I'm trying to use lambda expressions the following way:
```
var window_period = 10s
var current_period = data
|window()
.period(window_period)
.every(window_every)
.align()
var extended_period = data
|window()
.period(lambda: duration(int(window_period) * 2))
.every(window_every)
.align()
```
But it doesn't work, and produces the following error:
```
invalid TICKscript: line 57 char 10: error calling func "period" on obj *pipeline.WindowNode: reflect.Set: value of type *ast.LambdaNode is not assignable to type time.Duration
Contributor guide
Research direction
Start at the window() node's period handling and the reported reflect.Set error when a lambda expression is passed to period(). Trace how period() accepts its value and determine what behavior is required for the example to work; done means the shown lambda-based duration is accepted without the type error and existing window behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- stream-processing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100