[SERVER-74371] Support arbitrary expressions for 'field' parameter for $getField Created: 24/Feb/23 Updated: 01/Feb/24 Resolved: 03/Oct/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.2.0-rc0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Matthew Chiaravalloti | Assignee: | Henri Nikku |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||
| Assigned Teams: |
Query Optimization
|
||||||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||||||||||
| Sprint: | QO 2023-09-04, QO 2023-09-18, QO 2023-10-02, QO 2023-10-16 | ||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||
| Description |
|
The $getField operator only supports expressions that resolve to string literals. This ticket is requesting an expansion to $getField that would support any expressions that resolve to string values. For example,
|
| Comments |
| Comment by Andrea Santi [ 01/Feb/24 ] |
|
I suggest to update the documentation for the preivous versions of Mongodb.
The documentation says: "...to a string constant" It took us several hours to realize that we cannot use $myFieldPath |
| Comment by Andrea Santi [ 01/Feb/24 ] |
|
I suggest to update the documentation for the preivous versions of Mongodb.
The documentation says: "...to a string constant" It took us several hours to realize that we cannot use $myFieldPath |
| Comment by Githook User [ 03/Oct/23 ] |
|
Author: {'name': 'henrinikku', 'email': 'henri.nikku@mongodb.com', 'username': 'henrinikku'}Message: |
| Comment by Matthew Chiaravalloti [ 14/Mar/23 ] |
|
anton.korshunov@mongodb.com I figured that was exactly the case. I couldn't find the history of why this was rejected since I wasn't sure where to find the original design doc(s) for $getField. Figured I'd file this to find out if either it was already definitively ruled out or if it would be something you'd consider. Sounds like it is off the table! You can definitely close this as Won't Do. Thanks! |
| Comment by Alya Berciu [ 09/Mar/23 ] |
|
A note for triaging: this change should be quite simple in the code, as this was how the expression was originally implemented (see this line on the original commit). Might be worth having a follow-up fuzzer ticket to update the grammar to allow arbitrary strings in the field expression as well, if this gets scheduled. |
| Comment by Kyle Suarez [ 09/Mar/23 ] |
|
I spoke to alya.berciu@mongodb.com about this. During the course of PM-1856, there was a concern that allowing a non-constant input field would make optimization of that query difficult. However, to my knowledge there is not a hard reason that makes it impossible. Passing this ticket to the Query Optimization team for triage / prioritization. |