Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-48905

Allow $rand in command-level 'let'

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.7.0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • Query 2020-07-13, Query 2020-08-10, Query 2020-08-24

      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).

            Assignee:
            david.percy@mongodb.com David Percy
            Reporter:
            david.percy@mongodb.com David Percy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: