-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Support for Distinct Query #4195
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4195 +/- ##
==========================================
+ Coverage 92.22% 92.24% +0.01%
==========================================
Files 116 116
Lines 8089 8120 +31
==========================================
+ Hits 7460 7490 +30
- Misses 629 630 +1
Continue to review full report at Codecov.
|
I realized that arrays works differently between mongo and postgres.
Mongo returns
PG returns
I can make PG match the results from mongo by checking if I see a problem with nested arrays on PG since I can't check the type for array. Thoughs? |
We should have the same results on both DB’s can you point to the example test? |
If they should be the same I'll commit a solution shortly |
@flovilmart I think this is OK for now |
@dplewis, if we’re going with an aggregate api, do we want the distinct early on? |
Some users want it and it's easier to use than aggregate. What do you think? |
I think we need to be careful adding new API's more over, the classes/Object is supposedly returning a list of Parse Objects, not just an array of values (which would completely break all clients) |
I haven't tried using distinct/aggregate on clients yet so I don't know the end results. I don't want to break clients but are their any alternatives for these features? |
We also can make these REST exclusive |
Yeah but we need consistency. All Addind distinct as a query param, on the same endpoint would break that stability. However, on a new endpoint, like /aggregate/ClassName, we can guarantee that
what do you think? The code itself look great, I'm just pondering as it's a major shift from the current API stability, having a query param that triggers a completely different return type. |
You bring up a lot of good points. Let go that route (no pun intended) |
@dplewis even if the REST interface is a bit more verbose like
it's not that bad we can interpolate types, (key1, key2), structures etc... |
I understand now thanks for clarifying endpoints. |
@dplewis what do you think if I close that one for now, and we'll get it merged as part of a 1st iteration for aggregations? |
@flovilmart Sounds good to me. Quick question should we use for mongo db.Collection.distinct() or transform distinct into $group aggregate? |
Uhm, are they both the same? @TylerBrock? |
.distinct only supports 1 field but allows for queries. If we want to support key1, key2 we have to interpolate that into group with no query option or is there a work around? Theres also the issue of speed map-reduce (distinct) vs aggregate (group). I haven't done much research on these options. Thoughts? |
uhm, not much thoughts on that one! Hopefully @TylerBrock can probably point out something or someone from @mongodb like @christkv could shed some light! |
Another option is to get rid of the |
perhaps we can branch on the use case no? use .distinct() if certains params are passed otherwise use aggregation |
So the use cases would be Distinct one key Distinct multiple keys Aggregate How does that sound? |
What do you mean it will be overriden?
Actually they won't be in the where, but: GET /aggregate/MyClass?match=...&group=...&where=... And in that case match and where are equivalent no? As they filter the data set. Then the order of aggregation matters a lot, I'm not sure we can guarantee it through query params. |
Makes sense.
Does it? |
I believe itMa à pipeline, nothing prevents you to run match after group etc..: |
Ref: #2238, #2877
I added support for distinct query. Also works with nested queries.
Let me know if more tests should be added.