Skip to content

ungroup should return a stream if given a stream #2719

Open

Description

@neumino

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.

Activity

  1. coffeemug commented on Jul 18, 2014

    @coffeemug
    Contributor

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

  2. added this to the milestone on Jul 18, 2014
  3. mlucy commented on Jul 18, 2014

    @mlucy
    Member

    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.

  4. modified the milestones: , on Aug 13, 2014
  5. modified the milestones: , on Aug 20, 2014
  6. coffeemug commented on Aug 20, 2014

    @coffeemug
    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?

  7. mlucy commented on Aug 20, 2014

    @mlucy
    Member

    No objections.

  8. mlucy commented on Sep 9, 2014

    @mlucy
    Member

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

  9. modified the milestones: , on Sep 9, 2014
  10. 13 remaining items

  11. modified the milestones: 2.3, 2.2 on Oct 29, 2015
  12. modified the milestones: 2.3, on Nov 19, 2015
  13. modified the milestones: subsequent, on Feb 9, 2016
  14. self-assigned this
    on Mar 17, 2016
  15. marshall007 commented on Jun 24, 2016

    @marshall007
    Contributor

    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.

  16. ChrisTalman commented on Aug 15, 2019

    @ChrisTalman

    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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions