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

Improve error message when $documents stage is used on a collection aggregation

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • 7.0.5
    • None
    • None
    • Query Execution

    Description

      Running the following command on mongo v7.0.5, the error message wasn't clear for me.

      Enterprise test> db.test.aggregate([ { $documents: [{ nb: [1, 2, 3] }] }, { $project: { total: { $sum: ["$nb"] } } }] )
      MongoServerError: '$documents' can only be run with {aggregate: 1}

      I didn't know {aggregate: 1} was the literal expression of a database or cluster-level aggregation.

      Could you change the error message to make it more explicit:

      MongoServerError: '$documents' can only be run with database or cluster-level aggregation {aggregate: 1}

      Attachments

        Activity

          People

            backlog-query-execution Backlog - Query Execution
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: