[SERVER-6203] Aggregation operators should have well defined implicit type coercion behavior. Created: 25/Jun/12  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 2.1.2
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Andy Schwerin Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 11
Labels: expression, usability
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screenshot 2018-03-09 14.51.01.png    
Issue Links:
Depends
is depended on by SERVER-5239 $project should have numeric type coe... Closed
Duplicate
is duplicated by SERVER-6206 need a policy for incompatible types ... Closed
is duplicated by SERVER-11157 Type casting operator for aggregation... Closed
is duplicated by SERVER-22886 $type projection operator (cast types... Closed
Related
related to SERVER-8582 Extend document expression language i... Closed
related to SERVER-30461 aggregation $concat expression is inc... Backlog
related to SERVER-6120 Value::coerceToBool is inconsistent w... Closed
is related to SERVER-6197 $avg is calculated using integer math... Closed
is related to SERVER-6145 dividing two integers always produces... Closed
is related to SERVER-6166 consider expanding to wider data type... Closed
Assigned Teams:
Query Execution
Participants:

 Description   

Some expressions implicitly convert types, but this behavior is not always consistent or clearly documented.



 Comments   
Comment by Asya Kamsky [ 09/Mar/18 ]

The attached table shows the current implicit conversion behaviors. Top row are types to which conversions can be implicitly attempted. Example: any type can be used as conditional in $cond if: expression and it gets coerced to boolean type. Multiple string expressions ($substr,{$toUpper}, etc) will attempt to coerce a value to string. All date expressions try to coerce provided date to ISODate type.

Timestamp() BSON type is omitted from this table but it is generally treated same as ISODate() so anywhere date is expected Timestamp will successfully implicitly convert to date.

Comment by David Storch [ 06/Mar/18 ]

Explicit type conversion operators in the aggregation expression language have been implemented as the $convert operator under SERVER-32784 and related tickets. Shorthand syntax ($toInt, $toString, and so on) was implemented under SERVER-33510. These features were merged to the development branch recently, so documentation is not yet available (see DOCS-11386, e.g.).

I've narrowed this ticket to be about implicit type coercion behavior in the expression language (rather than about explicit conversion operators).

Comment by Raviteja [ 15/Feb/18 ]

Any ETA?

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