Well, you didn’t emit any values from your map function, so each row’s value will be null. I don’t think the sum function likes nulls; it expects numbers. Try emit(doc.brewery_id, 1).
The example in the documentation didn’t have a reduce function; it’s correct as an example of mapping. But when you’re reducing, the data being reduced is the values, so emitting a null value isn’t generally useful.