Kapacitor InfluxQL nodes and data type

The particular problem I’m having is that when count() is chained after where(), which is filtering a window()…

stream
| window().every(1s).period(60s)
| where(...)
| count('timestamp')

If the stream starts with data that does not fit the where criteria, count seems to initialize to an InfluxQL node for type float64. If the stream starts with data that does fit the where criteria, counts seems to initialize to an InfluxQL node for type int64.

The problem is if the count node starts as a float64 type, then when data meeting the where criteria start arriving, the timestamp type is int64, therefore kapacitor throws the following error

2017/03/23 17:14:13 E! failed to aggregate batch: field timestamp has wrong type: got int64 exp float64

I believe there is no way to coerce the data type for an InfluxQL node, and coercing timestamp to float64 would be the wrong thing to do.

Is my assessment above accurate? Am I misunderstanding some nuance of what’s going on?

So I changed kapacitor/influxql.go at master · influxdata/kapacitor · GitHub to int64(0) and that seems to the scenario I described above to pass without issue. I believe there should be a way for the user to specify what the default type should be rather than having it hard coded, especially since the type of reducer seems to be set based on the first point (or default) and then subsequent points are not coerced to match the type of the reducer.

Opened issue here InfluxQL default type should be settable by user · Issue #1271 · influxdata/kapacitor · GitHub

@sputnik13 Thank you for opening that issue!