Allow $rand in command-level 'let'

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: 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
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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 (Inactive)
            Reporter:
            David Percy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: