[SERVER-29971] Readable Aggregation Formulas Created: 04/Jul/17 Updated: 23/Nov/17 Resolved: 23/Nov/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Gabriel Zimmermann | Assignee: | Asya Kamsky |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Participants: | |||||||||
| Description |
|
When writing complex aggregation queries, the expressions can become difficult to read. Perhaps being able to provide a string that can be parsed to the current syntax might help simplifying expressions. Here is an example for a group stage:
Compared to this:
A simple stack structure could be used to transform the latter into the former. Obviously, there are scenarios in which you couldn't use this syntax to mirror the current implementation, but that's not the intention either. I've been going through some of our large aggregation queries and a lot of them are just formulas that could be made a lot easier to read if such a feature existed. |
| Comments |
| Comment by Asya Kamsky [ 23/Nov/17 ] |
|
Thanks for the suggestion. As you can see, Allowing the server to accept and parse strings in the pipeline would likely introduce potential security vulnerabilities as is the case in SQL, and it may not fully resolve the readability issue as not every possible aggregation could be written as a formula.
This is an excellent point - looking at a pipeline does not very easily allow one to visualize it as a common looking math expression. Of course one can always include math formula as a comment with the aggregation, but that has the risk of code and its comment diverging as people make edits, so that's not a solution that one could rely on. Whatever the solution is going to be, it will have to be implemented on the driver or client side, rather than in the server and that's why we are closing this ticket as "Won't Fix". Asya Kamsky |
| Comment by Kelsey Schubert [ 05/Jul/17 ] |
|
Hi arg20, Thank you for the feature request. I'm marking this ticket to be considered by the Query Team; please continue to watch for updates. Kind regards, |
| Comment by Gabriel Zimmermann [ 05/Jul/17 ] |
|
As a side comment, while true that a driver could implement this, I think that the degree of clarification this kind of syntax brings to the table merits some consideration for the database. For $group formulas it could really simplify the way aggregations look A LOT imho. |