[SERVER-48905] Allow $rand in command-level 'let' Created: 16/Jun/20 Updated: 29/Oct/23 Resolved: 17/Aug/20 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 4.7.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | David Percy | Assignee: | David Percy |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | qopt-team | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||
| Sprint: | Query 2020-07-13, Query 2020-08-10, Query 2020-08-24 | ||||||||||||
| Participants: | |||||||||||||
| Description |
|
Currently, command-level 'let' only accepts expressions that optimize to a constant. We'd like to allow $rand in a command-level 'let': it would pick a random value once up front, and the bound variable would be constant throughout the query. We can make this work by calling evaluate() instead of optimize(). But we should still report an error when the expression tries to refer to any field (as opposed to returning missing). We can use DepsTracker to uassert when the command-level-let-bound expressions have any unmet dependencies (fields, variables, or metadata). |
| Comments |
| Comment by Githook User [ 17/Aug/20 ] |
|
Author: {'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}Message: This relaxes a restriction on command-level 'let' bindings: instead of Referring to a field doesn't make sense in a command-level 'let', because Unbound variables are disallowed with the usual mechanism. |