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

Add let bounds to $project and $addFields (or new versions thereof)

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Query Optimization

      Currently, there is no way to share a computed expression between different fields of a $project or $addFields other than using a previous $project or $addFields. This proposes adding a let bound to precompute shared expressions. Due to the current syntax of $project and $addFields it seems we will need new pipeline stage names (or perhaps name let and projection $let and $projection?).

      Unable to find source-code formatter for language: json. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      {$addFieldsShared: 
         {
          let: {var1: expr1, var2: expr2, ...},
          projection: {field1: expr3, field2: expr4, ...}
         }
      }
      

      Where expr3 and expr4 can reference var1 and var2.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            patrick.meredith@mongodb.com Patrick Meredith
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: