[SERVER-6195] consider $concat to concatenate strings instead of overloading $add Created: 24/Jun/12  Updated: 26/Aug/17  Resolved: 18/Dec/12

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

Type: New Feature Priority: Major - P3
Reporter: Aaron Staple Assignee: Mathias Stearn
Resolution: Done Votes: 11
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-6570 disallow $add with strings Closed
Related
related to SERVER-6194 Nested $add operators may be improper... Closed
related to DOCS-949 $concat aggregation operator Closed
is related to SERVER-30461 aggregation $concat expression is inc... Backlog
Participants:

 Description   

There is a fair amount of implementation overhead for implementing both numeric addition and string concatenation with $add, and there are some related open tickets to fix: SERVER-6193, SERVER-6194.

Also I can see how '+' might be considered a convenience in javascript (though personally I would prefer a separate operator like '.'), but I'm not sure if there is a benefit in using the same $-expression to perform both addition and concatenation in the aggregation framework.

EDIT: $concat currently supports the following:

  • All number types are converted to their string representation
  • dates are converted to ISO-formatted strings
  • code, symbol and string are already string types
  • Null, undefined and missing fields ("nullish values") are converted to empty string
  • timestamps are converted to ctime format + the increment portion. e.g., "Wed Jun 30 21:49:08 1993"
  • all other types error out


 Comments   
Comment by Daniel Pasette (Inactive) [ 28/Jun/13 ]

marcin.floryan@comparethemarket.com, $cvoncat only works on strings – this ticket description is misleading. See SERVER-8239.

Comment by Marcin Floryan [ 28/Jun/13 ]

Could someone clarify - the description seems to suggest that concat supports multiple data types but it only appears to work for strings at the moment.

Comment by auto [ 20/Dec/12 ]

Author:

{u'date': u'2012-12-20T20:46:21Z', u'email': u'mathias@10gen.com', u'name': u'Mathias Stearn'}

Message: Fix test to not use collection.aggregate since it needs its own error handling

Follow up to SERVER-6195
Branch: master
https://github.com/mongodb/mongo/commit/d978f7f0ea41146dc60a7c0a0e7d1de768a296a7

Comment by auto [ 18/Dec/12 ]

Author:

{u'date': u'2012-07-24T21:29:40Z', u'name': u'Matt Dannenberg', u'email': u'dannenberg.matt@gmail.com'}

Message: SERVER-6195 implement $concat for strings in aggro

this also eliminates the problems seen in SERVER-6194

Note: modified by Mathias on 2012/12/17 to use new Doc/Val API
Branch: master
https://github.com/mongodb/mongo/commit/966fa94895fb5526367327c66f284dabbc566a8e

Comment by Paul Grinchenko [ 06/Dec/12 ]

We really would like to have this feature

Comment by auto [ 27/Jul/12 ]

Author:

{u'date': u'2012-07-24T06:59:40-07:00', u'email': u'dannenberg.matt@gmail.com', u'name': u'Matt Dannenberg'}

Message: SERVER-6570 disallow strings in $add in aggro

also started SERVER-6166 (ints overflowing to long in math) by doing the add portion
redo testall.js p20 when SERVER-6195 is done
Branch: master
https://github.com/mongodb/mongo/commit/d3b12c40a91d20dc5b86e40402308c7b2320f9a5

Comment by Mathias Stearn [ 24/Jul/12 ]

moving to 2.2 to keep it on the radar, but it is low priority and likely to be bumped 2.3.

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