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
@mlucy -- with the fact that the formats are different in the different drivers.
Users often try stuff in the data explorer, then translate their queries in python/ruby/go/etc. And basically with group, they won't be able to.
It's a little worse since this is useful when you build complicated queries, like with group for example.
We should have by default the same values in all three drivers. We can then have flags/options to change the format if the user want.
Ok, I'm leaning towards defining an object for the Javascript and Python drivers that supports iteration and getting a given group from the results. I believe this will satisfy a vast majority of the use cases, and allows us to make a wrap around the limitations of dicts/Objects in py and js (specifically that we cannot have dicts/Objects as keys).
I'm working on a Javascript implementation now of a GroupedData object that implements hasNext, next, each, toArray, and get, so people can play around with it and see how it feels. The python version should be much easier to do.
The idea is the same as the cursor, but the implementation is a little different since we're wrapping the GROUPED_DATA format. next could either return [<group>, <reduction>] or {group:<group>,reduction:<reduction>}, probably the latter since that is what we went with earlier.
I think we should mimic Ruby's object iteration interface; you should pass a callback to next that takes two arguments, and that callback should be called with key, value pairs.
@neumino -- the problem is that people call tbl.group('a').count(), and they get back [{group: ..., reduction: ...}, ...], and they're like "OK, I've got an array, I'll order that array by the reduction..." -- then they run tbl.group('a').count().orderBy('reduction'), and it doesn't do what they expect.
Then maybe they go read the docs, they find out about this "ungroup", and they're like OK, and they run tbl.group('a').count().ungroup(), and they get back...the exact same thing they got before ([{group: ..., reduction: ...}, ...]). And they're like "what the fuck does ungroup do?". The idea that the type you get on the client corresponds the the type you get on the server if you call ungroup is really hard to explain.
Do avoid the confusion, can we not send grouped results back to the clients and force them to use ungroup? We could also have ungroup_as_object() or ungroup(object=true).
You mean just return the pseudotype in JS? I think that would be better than what we have now, but I'd like to see what the interface @Tryneus is working on feels like in practice.
@AtnNn -- Forcing people to always call ungroup at the end seems like it would get super annoying. (Also, I think the object format of GROUPED_DATA is what you actually want to get back in Ruby.)
Although, maybe my first instincts on this are wrong. @coffeemug, what do you think?
And they will never know that they have a grouped_data object. Returning a new type of object doesn't solve the problem.
Node.js users don't use the shell as python users can.
I also don't see what's wrong with the explanation of group/ungroup I gave in my previous comment.
We shouldn't worry about the driver not always matching the type of a result with the type in the server.
Having to deal with array and cursor is already confusing -- and if someone thinks it's not, and wants to reopen this debate, I would be happy to go through my logs to show concrete example of confused users.
Adding a grouped_data is exactly the same thing (maybe worst).
If we keep matching the driver and the server, we are going to end up adding a new type of object for numbers since JavaScript numbers are just 32 bits double.
@neumino -- I can't speak for all users, but it is SUPER confusing in the data explorer. Saying "the behavior is well-defined and can be explained" doesn't really matter when the first-touch experience of using it is confusing and complicated. Having two types which don't behave the same way but which are displayed exactly the same way in the data explorer is too confusing to ship with, even if we can explain to users why it is that way.
(Also, to clarify what I mean by confusing, Slava's first intuition was that he could call orderBy('reduction') on the output of .group('a').count(), and he helped design the feature. It would have been my first intuition too if I hadn't implemented the server behavior.)
We can just improve the error message, in case an error (maybe just some of them) is thrown in a group_data/group_streams, we can suggest that maybe they want to ungroup before.
I still think that adding a new type is not the solution here and is just going to end up as a burden for our users.
Note: The data explorer already presents cursor and arrays the same way.
I think the biggest benefit of adding a wrapper class is that we can allow random access of the results, which might be a pain for users to do themselves. Avoiding confusing users is nice, but we should focus on what makes a simple and usable interface. At this point, I'm not convinced the wrapper classes are a good idea, if we just return [{group:<group>,reduction:<reduction>}...], and let users handle it from there, I think that is enough.
I very strongly disagree with @AtnNn's proposal. Forcing people to call ungroup to get the data back is extremely annoying. I think doing that would cut the pleasantness of this feature in half.
I'm also very strongly opposed to representing GROUP_DATA in JS via the same object that the user would get by calling ungroup. That's extremely confusing.
Instead of building a custom wrapper, why don't we just construct a native JavaScript object (like we do in Ruby)?
Err, actually I'm opposed to the last part (constructing a native JS object), all the automagical conversion to strings is just terrible.
So it's between a custom object or an array of pairs (an array of arrays, basically). I think an array of pairs is easiest: [['nyc', 2], ['sf', 1]]. If people want a proper {group: ..., reduction: ...} they can call ungroup.
@coffeemug -- an array of pairs solves half the confusion ("the output is the same whether or not I call ungroup", but not "I'm getting back an array but I can't chain functions on the end like I expect"). If we have to do something like this, we should return something that doesn't look like another type in our type system (e.g. we could return the raw psuedotype).
@neumino -- we can't just solve this with a better error message because sometimes we just do the wrong thing rather than causing an error. For example, if the user writes tbl.group('a').min('a').pluck('reduction'), they probably expect to get back an array like [{reduction: ...}, ...], but instead they get back [{group: ..., reduction: {}}, ...].
@Tryneus -- "confusing" and "simple and usable" or not orthogonal. In this case, I think confusion is our biggest usability problem.
an array of pairs solves half the confusion ("the output is the same whether or not I call ungroup", but not "I'm getting back an array but I can't chain functions on the end like I expect"
I see. I think the latter is a smaller problem, though. Also, this will be a problem with the way we present the results in the data explorer.
Let me know if you need me to rally people together in a room and such (we do need to arrive at a good solution, as this is stretching).
Regarding the changes we discussed to the returned dict object in python, it is actually impossible to modify those attributes on a dict, we would need a new type.
Activity
coffeemug commentedon Feb 27, 2014
Also a note that @neumino is really unhappy with the state of affairs too (though for different reasons, I think).
mlucy commentedon Feb 27, 2014
@neumino -- are you unhappy with the format in JS, or with the fact that the formats are different in the different drivers?
neumino commentedon Feb 27, 2014
@mlucy -- with the fact that the formats are different in the different drivers.
Users often try stuff in the data explorer, then translate their queries in python/ruby/go/etc. And basically with
group, they won't be able to.It's a little worse since this is useful when you build complicated queries, like with
groupfor example.We should have by default the same values in all three drivers. We can then have flags/options to change the format if the user want.
Tryneus commentedon Feb 27, 2014
Ok, I'm leaning towards defining an object for the Javascript and Python drivers that supports iteration and getting a given group from the results. I believe this will satisfy a vast majority of the use cases, and allows us to make a wrap around the limitations of dicts/Objects in py and js (specifically that we cannot have dicts/Objects as keys).
I'm working on a Javascript implementation now of a GroupedData object that implements
hasNext,next,each,toArray, andget, so people can play around with it and see how it feels. The python version should be much easier to do.neumino commentedon Feb 27, 2014
Isn't the
GroupedDataobject just a cursor then?What does the user get back with
groupedData.next?Tryneus commentedon Feb 27, 2014
The idea is the same as the cursor, but the implementation is a little different since we're wrapping the GROUPED_DATA format.
nextcould either return[<group>, <reduction>]or{group:<group>,reduction:<reduction>}, probably the latter since that is what we went with earlier.mlucy commentedon Feb 27, 2014
I think we should mimic Ruby's object iteration interface; you should pass a callback to
nextthat takes two arguments, and that callback should be called withkey, valuepairs.neumino commentedon Feb 27, 2014
After a
groupcommand and as long you haven't callungroup, all the methods you call are going to be executed on each group.It's as simple as that.
I don't understand why we need to create a new type in the driver.
mlucy commentedon Feb 27, 2014
@neumino -- the problem is that people call
tbl.group('a').count(), and they get back[{group: ..., reduction: ...}, ...], and they're like "OK, I've got an array, I'll order that array by the reduction..." -- then they runtbl.group('a').count().orderBy('reduction'), and it doesn't do what they expect.Then maybe they go read the docs, they find out about this "ungroup", and they're like OK, and they run
tbl.group('a').count().ungroup(), and they get back...the exact same thing they got before ([{group: ..., reduction: ...}, ...]). And they're like "what the fuck does ungroup do?". The idea that the type you get on the client corresponds the the type you get on the server if you callungroupis really hard to explain.AtnNn commentedon Feb 27, 2014
Do avoid the confusion, can we not send grouped results back to the clients and force them to use
ungroup? We could also haveungroup_as_object()orungroup(object=true).mlucy commentedon Feb 27, 2014
You mean just return the pseudotype in JS? I think that would be better than what we have now, but I'd like to see what the interface @Tryneus is working on feels like in practice.
AtnNn commentedon Feb 27, 2014
@mlucy no, I mean that
.run()on agrouped_streamorgrouped_datumswould be an error.mlucy commentedon Feb 27, 2014
@AtnNn -- Forcing people to always call
ungroupat the end seems like it would get super annoying. (Also, I think the object format of GROUPED_DATA is what you actually want to get back in Ruby.)Although, maybe my first instincts on this are wrong. @coffeemug, what do you think?
neumino commentedon Feb 27, 2014
They are going to run
And they will never know that they have a
grouped_dataobject. Returning a new type of object doesn't solve the problem.Node.js users don't use the shell as python users can.
I also don't see what's wrong with the explanation of
group/ungroupI gave in my previous comment.We shouldn't worry about the driver not always matching the type of a result with the type in the server.
Having to deal with array and cursor is already confusing -- and if someone thinks it's not, and wants to reopen this debate, I would be happy to go through my logs to show concrete example of confused users.
Adding a
grouped_datais exactly the same thing (maybe worst).If we keep matching the driver and the server, we are going to end up adding a new type of object for numbers since JavaScript numbers are just 32 bits double.
mlucy commentedon Feb 28, 2014
@neumino -- I can't speak for all users, but it is SUPER confusing in the data explorer. Saying "the behavior is well-defined and can be explained" doesn't really matter when the first-touch experience of using it is confusing and complicated. Having two types which don't behave the same way but which are displayed exactly the same way in the data explorer is too confusing to ship with, even if we can explain to users why it is that way.
mlucy commentedon Feb 28, 2014
Also, I think the iteration would be something like:
mlucy commentedon Feb 28, 2014
(Also, to clarify what I mean by confusing, Slava's first intuition was that he could call
orderBy('reduction')on the output of.group('a').count(), and he helped design the feature. It would have been my first intuition too if I hadn't implemented the server behavior.)neumino commentedon Feb 28, 2014
We can just improve the error message, in case an error (maybe just some of them) is thrown in a
group_data/group_streams, we can suggest that maybe they want toungroupbefore.I still think that adding a new type is not the solution here and is just going to end up as a burden for our users.
Note: The data explorer already presents cursor and arrays the same way.
Tryneus commentedon Feb 28, 2014
I think the biggest benefit of adding a wrapper class is that we can allow random access of the results, which might be a pain for users to do themselves. Avoiding confusing users is nice, but we should focus on what makes a simple and usable interface. At this point, I'm not convinced the wrapper classes are a good idea, if we just return
[{group:<group>,reduction:<reduction>}...], and let users handle it from there, I think that is enough.neumino commentedon Feb 28, 2014
We can return an ArrayResult then.
coffeemug commentedon Feb 28, 2014
I very strongly disagree with @AtnNn's proposal. Forcing people to call
ungroupto get the data back is extremely annoying. I think doing that would cut the pleasantness of this feature in half.I'm also very strongly opposed to representing GROUP_DATA in JS via the same object that the user would get by calling
ungroup. That's extremely confusing.Instead of building a custom wrapper, why don't we just construct a native JavaScript object (like we do in Ruby)?
coffeemug commentedon Feb 28, 2014
Err, actually I'm opposed to the last part (constructing a native JS object), all the automagical conversion to strings is just terrible.
So it's between a custom object or an array of pairs (an array of arrays, basically). I think an array of pairs is easiest:
[['nyc', 2], ['sf', 1]]. If people want a proper{group: ..., reduction: ...}they can callungroup.How about that?
mlucy commentedon Feb 28, 2014
@coffeemug -- an array of pairs solves half the confusion ("the output is the same whether or not I call
ungroup", but not "I'm getting back an array but I can't chain functions on the end like I expect"). If we have to do something like this, we should return something that doesn't look like another type in our type system (e.g. we could return the raw psuedotype).@neumino -- we can't just solve this with a better error message because sometimes we just do the wrong thing rather than causing an error. For example, if the user writes
tbl.group('a').min('a').pluck('reduction'), they probably expect to get back an array like[{reduction: ...}, ...], but instead they get back[{group: ..., reduction: {}}, ...].@Tryneus -- "confusing" and "simple and usable" or not orthogonal. In this case, I think confusion is our biggest usability problem.
coffeemug commentedon Feb 28, 2014
I see. I think the latter is a smaller problem, though. Also, this will be a problem with the way we present the results in the data explorer.
Let me know if you need me to rally people together in a room and such (we do need to arrive at a good solution, as this is stretching).
Tryneus commentedon Mar 4, 2014
Regarding the changes we discussed to the returned dict object in python, it is actually impossible to modify those attributes on a dict, we would need a new type.
coffeemug commentedon Mar 4, 2014
Ok, closing this issue.
I've opened #2054 for an infobox in the data explorer.