Skip to content

Rename groups_to_array to ungroup #2033

Closed

Description

@mlucy

After talking with @coffeemug, this is a common enough operation that it should be short.

He also proposed adding optargs group_name and reduction_name, because apparently people have asked in the past for an easy way to rename the group and reduction. (So tbl.group('a').ungroup(group_name:'foo', reduction_name:'bar') would have output of the form [{foo: ..., bar: ...}, ...].)

Any objections to this?

Activity

  1. added this to the 1.12 milestone on Feb 27, 2014
  2. self-assigned this
    on Feb 27, 2014
  3. AtnNn commented on Feb 27, 2014

    @AtnNn
    Member

    How about also adding an as_object optarg that would output as {...: ..., ...} and fail if the group is not a string.

  4. mlucy commented on Feb 27, 2014

    @mlucy
    MemberAuthor

    I'm not totally opposed to that, but it seems less generally useful.

  5. coffeemug commented on Feb 27, 2014

    @coffeemug
    Contributor

    tbl.group('a').ungroup(group_name:'foo', reduction_name:'bar')

    Any way we can shorten this? Typing all this up is a pain. For example:

    tbl.group('a').ungroup()
    tbl.group('a').ungroup('my_group')
    tbl.group('a').ungroup('my_group', 'my_reduction')
    tbl.group('a').ungroup(null, 'my_reduction')

    Soooo much nicer.

    How about also adding an as_object optarg

    Could we hold off on this until we learn a bit more about what we want to do with #2032?

  6. mlucy commented on Feb 27, 2014

    @mlucy
    MemberAuthor

    Positional arguments are a little weird here because when you're reading an ungroup query it isn't clear what they mean. If I saw seq.ungroup(nil, 'best_game') I would assume we were ungrouping based on the field best_game or something.

  7. coffeemug commented on Feb 27, 2014

    @coffeemug
    Contributor

    True. What do others think?

  8. coffeemug commented on Mar 5, 2014

    @coffeemug
    Contributor

    A friendly reminder that it would be nice to work the last bit (renaming) out. Ping @neumino @mglukhovsky. What would you prefer?

  9. neumino commented on Mar 5, 2014

    @neumino
    Member

    I personally like ungroup but I don't like the idea of passing an optarg to rename the groups.
    We should implement #881 instead of adding the optarg.

    toArray would be confusing because of cursor.toArray
    groupsToArray is long and kind of confusing I think since the user just sees an array if he runs table(..).group(...)

  10. coffeemug commented on Mar 5, 2014

    @coffeemug
    Contributor

    So, the reason I wanted to do the optarg is because I heard many, many times that people hate the names group and reduction and would like an easy way to rename the fields. We will eventually implement rename, but that's still annoying -- you'll have to call ungroup and rename to get what you want. Since people will frequently want to ungroup and rename, I think it makes sense to special case ungroup to support this functionality for convenience.

    (Also, to limit the scope of the discussion, I think ungroup is a fine name and we should leave it as is).

  11. neumino commented on Mar 5, 2014

    @neumino
    Member

    Yep, I see what you mean, but I'm still not a big fan of the optarg.

    I'm not strongly opposed though, so I'm ok shipping it with @mlucy's proposal.

  12. mglukhovsky commented on Mar 5, 2014

    @mglukhovsky
    Member

    I dislike ungroup, but can't think of a better name that describes the operation, so I'm abstaining.

  13. coffeemug commented on Mar 5, 2014

    @coffeemug
    Contributor

    @mlucy -- ok the renaming thing is up to you. I'm ok with using your syntax, or not shipping it at all now, and dealing with this later (I think I'd prefer that, actually).

    Let us know what you want to do.

  14. mglukhovsky commented on Mar 5, 2014

    @mglukhovsky
    Member

    Here's an idea: you could do a write-up of the problem as a gist, post it
    on Google Groups, Twitter, IRC, see what users have to say.

    Or wait to resolve this after the release.

    On Tue, Mar 4, 2014 at 6:07 PM, Slava Akhmechet [email protected]:

    @mlucy https://github.com/mlucy -- ok the renaming thing is up to you.
    I'm ok with using your syntax, or not shipping it at all now, and dealing
    with this later (I think I'd prefer that, actually).

    Let us know what you want to do.

    Reply to this email directly or view it on GitHubhttps://github.com//issues/2033#issuecomment-36702940
    .

  15. coffeemug commented on Mar 5, 2014

    @coffeemug
    Contributor

    This one isn't worth writing up. I do like the general idea of advertising RFCs -- we should do that more.

  16. mlucy commented on Mar 5, 2014

    @mlucy
    MemberAuthor

    This is easy to add later. This release is already behind schedule, so I'd like to just leave it for now.

  17. neumino commented on Mar 5, 2014

    @neumino
    Member

    Just to be sure, ungroup is in next right? And what we are not shipping is just the optarg?

  18. coffeemug commented on Mar 5, 2014

    @coffeemug
    Contributor

    @neumino -- correct.

    This issue is done. Closing.

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

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions