Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-207

M/R raises a DB assert if output parameter is not specified.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.10
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      1.7.5

      Problem:

      When connecting to a 1.6.x DB, running a mapReduce only needs two params, e.g.

      result = db.articles.map_reduce(map, reduce)

      However, running the same M/R against 1.7.x you get

      pymongo.errors.OperationFailure: command SON([('mapreduce', u'articles'), ('map', Code('function() {\nnew_date = new Date(this.link_time);\nout_date = new_date.getFullYear() + "" + (new_date.getMonth() + 1) + "" + new_date.getDate()\nemit(out_date,

      {count:1}

      );\n}', {})), ('reduce', Code("function(key, values) {\nvar count = 0;\nvalues.forEach(function(v)

      {\n count += v['count'];\n}

      );\nreturn

      {timeline: key, count : count}

      ;\n}", {}))]) failed: db assertion failure

      Runing this in the shell you see the following on 1.7.x

      Mon Feb 14 20:45:58 uncaught exception: map reduce failed: {
      "assertion" : "'out' has to be a string or an object",
      "assertionCode" : 13606,
      "errmsg" : "db assertion failure",
      "ok" : 0

      Workaround:
      Add the extra out parameter, e.g.

      result = db.articles.map_reduce(map, reduce, out="i180days")

      Solution:
      1) Force the output to either be mandatory of default to inline for backward compatibility
      2) Update the API and Examples

      See Also:
      http://www.mongodb.org/display/DOCS/MapReduce#MapReduce-Outputoptions

      Business Case:

      • backward compatibility is broken with 1.8.x

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            alvin Alvin Richards (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: