The $zip operator receives only an array literal as 'defaults'

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The syntax definition of $zip states that 'defaults' receives an <array expression>, but if we invoke $zip with anything other than an array literal in defaults, it shows this error:

      Invalid $project :: caused by :: defaults must be an array of expressions, found string : aggregate failed

      Instead, expressions that resolve to arrays should also be accepted.

      How to reproduce

      The code below should output [[1,"A"],[2,"B"],[3,"y"]].

      db.coll.insert({'short': ['x', 'y']});
      zipObj = {
          inputs: [[1, 2, 3], ["A", "B"]],
          defaults: "$short",
          useLongestLength: true
      };
      db.coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]); 

            Assignee:
            Unassigned
            Reporter:
            Felipe Goron Farinon
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: