Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doing an collate -a avg,... on an empty stream dies. #65

Open
anall opened this issue Jun 11, 2015 · 6 comments
Open

Doing an collate -a avg,... on an empty stream dies. #65

anall opened this issue Jun 11, 2015 · 6 comments
Labels

Comments

@anall
Copy link

anall commented Jun 11, 2015

$ 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.
@benbernard
Copy link
Owner

thanks for the report!

@tsibley
Copy link
Collaborator

tsibley commented Feb 26, 2016

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:

  1. Outputting an empty stream
  2. Outputting a single record (the aggregate) with some null/empty value. Part of this choice is choosing 0 vs. undef agg values when, say, using count on an empty stream.

Thoughts?

@benbernard
Copy link
Owner

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

@anall
Copy link
Author

anall commented Feb 26, 2016

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.

@benbernard
Copy link
Owner

yeah, agreed, given large chains of filters, it feels to me like nothing is the right answer

@tsibley
Copy link
Collaborator

tsibley commented Feb 28, 2016

That sounds good to me. Will do!

@tsibley tsibley added the bug label Feb 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants