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

Variadic expressions have inconsistent query shapes

    • Query Integration
    • Fully Compatible
    • ALL
    • 18

      We noticed some interesting behavior for query shapes with variadic expressions (e.g. $multiply, $sum, etc). Here are some contrasting examples:

      db.c.aggregate([{$group: {_id: {$multiply: [1, 2, {$const: 3}]}}}]) 

      is simplified to

      {"$group": {"_id": {"$multiply": "?array<?number>"}}} 

      while 

      db.c.aggregate([{$group: {_id: {$multiply: [1, {$const: 1}, {$expr: {$sum: [1]}}]}}}]) 

      is generally preserved as

      {"$group": {"_id": {"$multiply": ["?number", "?number", "$myField", {"$sum": "?array<?number>"}]}}} 

      It's not clear what the desirable behavior here (there's a tradeoff between a possibly high cardinality of query shapes vs losing details of the user's original query), but it seems like the behavior between these two cases should not be so different.

            Assignee:
            alyssa.clark@mongodb.com Alyssa Clark
            Reporter:
            alyssa.clark@mongodb.com Alyssa Clark
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: