[SERVER-7185] Aggregation should support Symbol type Created: 27/Sep/12  Updated: 28/Oct/15  Resolved: 11/Dec/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 2.2.0
Fix Version/s: 2.3.2

Type: Bug Priority: Critical - P2
Reporter: Ry Walker Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ruby 1.9.3, OSX Mountain Lion


Operating System: ALL
Steps To Reproduce:

Renaming to reflect scope of issue (not just $group)

Participants:

 Description   

I'm getting an error in aggregation framework for a field that is stored as BSON Symbol using Mongoid's `symbolize` method.

Any way around this besides not storing the data as a symbol? The bad field below is '$bucket_type'

 
class TestAggregation
  def self.data
    command = {
      aggregate: 'cohort_generics',
      pipeline: [
        {
          '$match' => {
            product_id: 2,
            created_at: {
              '$gte' => 1.month.ago
            }
          }
        },
        {
          '$group' => {
            _id: {
              startDate: '$start_date',
              type: '$_type',
              bucket_type: '$bucket_type'
            },
            people: { '$sum' => 1 }
          }
        }
      ]
    }
 
    Mongoid.default_session.command(command)['result']
  end
end

Moped::Errors::OperationFailure: The operation: #<Moped::Protocol::Command
  @length=290
  @request_id=2
  @response_to=0
  @op_code=2004
  @flags=[]
  @full_collection_name="usercycle.$cmd"
  @skip=0
  @limit=-1
  @selector={:aggregate=>"cohort_generics", :pipeline=>[{"$match"=>{:product_id=>2, :created_at=>{"$gte"=>Mon, 27 Aug 2012 18:07:53 UTC +00:00}}}, {"$group"=>{:_id=>{:startDate=>"$start_date", :type=>"$_type", :bucket_type=>"$bucket_type"}, :people=>{"$sum"=>1}}}]}
  @fields=nil>
failed with error 16002: "exception: can't create Value of BSON type Symbol"
 
See https://github.com/mongodb/mongo/blob/master/docs/errors.md
for details about this error.



 Comments   
Comment by auto [ 11/Dec/12 ]

Author:

{u'date': u'2012-11-29T19:54:48Z', u'email': u'mathias@10gen.com', u'name': u'Mathias Stearn'}

Message: Add at least minimal support for all types to agg

Minimal support means conversion to/from BSON, comparison and hashing.
This means that they can be passed through the pipeline correctly, used
in $sort, and used in _id expressions in $group.

SERVER-4608 - Binary pass through
SERVER-5718 - Code/CodeWScope pass through
SERVER-6470 - Don't convert Regex to String
SERVER-7185 - Symbol support
Branch: master
https://github.com/mongodb/mongo/commit/fefb4334afe40664438668a289c6daed6813b3c3

Comment by Ry Walker [ 28/Sep/12 ]

Thanks for quick response — I did see the warning later in the afternoon. Can close issue.

Comment by Daniel Pasette (Inactive) [ 28/Sep/12 ]

At this time you still can't use the following types: Binary, Symbol, MinKey, MaxKey, DBRef, Code, and CodeWScope
See the warning here: http://docs.mongodb.org/manual/applications/aggregation/

Generated at Thu Feb 08 03:13:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.