RecordStream
RecordStream copied to clipboard
Doing an `collate -a avg,...` on an empty stream dies.
$ echo -n "" | recs collate -k foo -a avg,bar
Can't use an undefined value as an ARRAY reference at
/home/anall/perl5/lib/perl5/App/RecordStream/Aggregator/Average.pm line 22.
thanks for the report!
The fix for avg
is pretty simple, but it seems that many of the aggregators don't define their behaviour when processing an empty stream (although many do!). I'd like to fix them all at once, standardizing behaviour.
Before I delve into adding empty stream tests to all the aggs and then fixing whatever fails, I want to figure out what the desired behaviour should be. I can see both cases:
- Outputting an empty stream
- Outputting a single record (the aggregate) with some null/empty value. Part of this choice is choosing
0
vs.undef
agg values when, say, usingcount
on an empty stream.
Thoughts?
Ideally, I think we should just define this behavior for all scripts... and I think it should just pass on nothing. I could also see erroring (but perhaps with a better error). Let me also see if @amling wants to weigh in on this
Nothing matches with what I was expecting ( with a much more complex chain of things that legitimately filtered all records ) when I ran into this.
yeah, agreed, given large chains of filters, it feels to me like nothing is the right answer
That sounds good to me. Will do!