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

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

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • Aggregation Framework
    • None
    • Query Optimization

    Description

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

      {$addFieldsShared: 
         {
          let: {var1: expr1, var2: expr2, ...},
          projection: {field1: expr3, field2: expr4, ...}
         }
      }
      

      Where expr3 and expr4 can reference var1 and var2.

      Attachments

        Activity

          People

            backlog-query-optimization Backlog - Query Optimization
            patrick.meredith@mongodb.com Patrick Meredith
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: