[SERVER-39487] Aggregation operator $sqrt output for NumberDecimal is the same as $exp Created: 11/Feb/19 Updated: 29/Oct/23 Resolved: 20/Feb/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | 4.0.5, 4.1.6 |
| Fix Version/s: | 3.4.21, 3.6.12, 4.0.7, 4.1.9 |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | Wan Bachtiar | Assignee: | James Wahlin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Backwards Compatibility: | Fully Compatible | ||||
| Operating System: | ALL | ||||
| Backport Requested: |
v4.0, v3.6, v3.4
|
||||
| Sprint: | Query 2019-02-25 | ||||
| Participants: | |||||
| Description |
|
Using the following documents:
Running aggregation operator $sqrt as below:
Produces:
Note that the output of the $sqrt is the same as the output of $exp. Decimal128::squareRoot: Decimal128::exponential: A workaround is to convert the decimal to double first i.e. $toDouble, to bypass the squareRoot method call in expression: https://github.com/mongodb/mongo/blob/r4.1.6/src/mongo/db/pipeline/expression.cpp#L4091 For example:
|
| Comments |
| Comment by Githook User [ 18/Mar/19 ] |
|
Author: {'email': 'james@mongodb.com', 'name': 'James Wahlin', 'username': 'jameswahlin'}Message: (cherry picked from commit 5aa3f6dbc5e31beaf40e0828f7a24ecf71fb42f9) |
| Comment by Githook User [ 15/Mar/19 ] |
|
Author: {'email': 'james@mongodb.com', 'name': 'James Wahlin', 'username': 'jameswahlin'}Message: (cherry picked from commit 5aa3f6dbc5e31beaf40e0828f7a24ecf71fb42f9) |
| Comment by Githook User [ 22/Feb/19 ] |
|
Author: {'name': 'James Wahlin', 'email': 'james@mongodb.com', 'username': 'jameswahlin'}Message: (cherry picked from commit 5aa3f6dbc5e31beaf40e0828f7a24ecf71fb42f9) |
| Comment by Githook User [ 20/Feb/19 ] |
|
Author: {'name': 'James Wahlin', 'email': 'james@mongodb.com', 'username': 'jameswahlin'}Message: |
| Comment by Andy Schwerin [ 12/Feb/19 ] |
|
Not strictly related, but the overload of exponential that takes no flags is throwing away the caller-supplied rounding mode argument. The implementation of `squareRoot` that takes user flags is correct. The version that does not is delegating to the `exponential` by accident. This would be a good opportunity to also expand our C++ unit test coverage of the wrapper. |