You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm rewriting our election tutorial to use the new gmr, and it would be waaay nicer if you could write table.group('id').avg('Dem', 'GOP') to get back {Dem: DEM_AVG, GOP: GOP_AVG}.
I think we should do what I wrote above for avg, sum, min, max, and count.
There's a small wrinkle, which is that you can pass functions to aggregators as well as field names. I think in that case we should use an ordinal (the offset of the function) as the name in the resulting object. So tbl.group('id').avg(lambda{|row| row['dem']}, lambda {|row| row['gop']}) would return {1: DEM_AVG, 2: GOP_AVG}.
I'm not opposed to adding a way to do arbitrary combinations of reductions, but it's a lot more work (and a much more contentious API discussion). I think that should be a separate issue (e.g. #1725).
I wouldn't be opposed to ignoring this issue and jus waiting until we have enough time to discuss/implement the more complicated thing.
Activity
coffeemug commentedon Mar 11, 2014
Note, this is related to #1725.
coffeemug commentedon Sep 4, 2014
Also note, we should consider doing this for other aggregators.
mlucy commentedon Sep 9, 2014
I think we should do what I wrote above for
avg,sum,min,max, andcount.There's a small wrinkle, which is that you can pass functions to aggregators as well as field names. I think in that case we should use an ordinal (the offset of the function) as the name in the resulting object. So
tbl.group('id').avg(lambda{|row| row['dem']}, lambda {|row| row['gop']})would return{1: DEM_AVG, 2: GOP_AVG}.coffeemug commentedon Sep 11, 2014
That sounds great, with the exception that ordinals should start at zero, not one. What kind of barbarism is this?!
neumino commentedon Sep 11, 2014
This partially solves the problem.
We can't get the sum of a field and the average of another field without manually doing a map/reduce.
What about adding an aggregator command that would work like this:
mlucy commentedon Sep 11, 2014
I'm not opposed to adding a way to do arbitrary combinations of reductions, but it's a lot more work (and a much more contentious API discussion). I think that should be a separate issue (e.g. #1725).
I wouldn't be opposed to ignoring this issue and jus waiting until we have enough time to discuss/implement the more complicated thing.
coffeemug commentedon Sep 11, 2014
I still think we should implement this -- it's really useful. I'd like #1725 to go into the next ReQL discussion.
mlucy commentedon Sep 19, 2014
Marking as settled. We'll do what I said in #2078 (comment) . We'll discuss a more general way to do multiple aggregations in #1725.
This is lower-priority then some other things since it's just convenient rather than being powerful enough to solve the multiple aggregations problem.
6 remaining items