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

ungroup should return a stream if given a stream #2719

Open
neumino opened this issue Jul 18, 2014 · 8 comments
Open

ungroup should return a stream if given a stream #2719

neumino opened this issue Jul 18, 2014 · 8 comments

Comments

@neumino
Copy link
Member

neumino commented Jul 18, 2014

If the table "test" has more than 100k elements, this is going to throw:

r.table("test").group({index: "date"}).ungroup()

Tackling a ungroup command at the end is useful if you want to rename some fields for example.

Not sure if it's a bug or a proposal. Feel free to tag and move to the appropriate milestone.

@coffeemug
Copy link
Contributor

@mlucy -- what's the expected behavior in this case?

@mlucy mlucy added this to the 1.14-polish milestone Jul 18, 2014
@mlucy
Copy link
Member

mlucy commented Jul 18, 2014

This is possible in the specific case where you're grouping by an index, and I think we should support it. I'd classify it as a proposal because it requires new logic, it isn't a matter of just fixing broken behavior. Tagging as a proposal and putting in 1.14-polish.

@coffeemug coffeemug modified the milestones: 1.14-polish, 1.15-polish Aug 13, 2014
@coffeemug coffeemug modified the milestones: 1.15-polish, reql-discussion Aug 20, 2014
@coffeemug
Copy link
Contributor

From an API perspective I think this is clear, but putting in reql-discussion for bureaucratic reasons.

Does anyone object if we mark it as settled?

@mlucy
Copy link
Member

mlucy commented Aug 20, 2014

No objections.

@mlucy
Copy link
Member

mlucy commented Sep 9, 2014

Moving out of reql-discussion since it's settled.

@mlucy mlucy modified the milestones: 1.16-polish, reql-discussion Sep 9, 2014
@danielmewes danielmewes modified the milestones: 1.16-polish, subsequent Jan 2, 2015
@danielmewes danielmewes modified the milestones: 2.1-polish, subsequent Mar 26, 2015
@danielmewes
Copy link
Member

This comes up quite a bit in user queries btw. I'm not sure if we'll have time to do this in 2.2, but we should try to not push this off too far.

@marshall007
Copy link
Contributor

marshall007 commented Jun 24, 2016

A workaround for this is to use distinct which emits the group values lazily and still allows the reductions to be performed across all shards. This is much faster than native group in every case I've tried:

r.table('test')
  .distinct({ index: 'date' })
  .map({
    group: r.row,
    reduction: r.table('test').getAll(r.row, { index: 'date' }).count()
  })

@danielmewes noted the only difference between this rewrite and .group(...) is that the distinct can result in empty groups if a document is modified while the query is being run.

@ChrisTalman
Copy link

Out of curiosity, has this been implemented in 2.4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants