[SERVER-29410] Enhance aggregation to handle handle NaN and +/- infinity Created: 31/May/17  Updated: 06/Dec/22

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

Type: Improvement Priority: Major - P3
Reporter: Rintcius Blok Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: mql-semantics
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-6144 Aggregation should error out on divid... Closed
Assigned Teams:
Query Optimization
Participants:

 Description   

Pipeline expressions containing NaN and +/- infinity give a server error (e.g. "can't $divide by zero").
However BSON is able to represent NaN and infinity, so it's expected that the appropriate values are being used instead.



 Comments   
Comment by Ramon Fernandez Marina [ 20/Jul/17 ]

I'm reopening this issue for the Query team to weigh in on whether handling +inf/-inf/NaN in the aggregation pipeline is feasible; there are other related tickets so this request may be folded into one of them.

Comment by Rintcius Blok [ 12/Jun/17 ]

Hi Mark, from my view the current behaviour looked like an obvious bug (and it still does, to be clear) so that's why I reported it here rather than in the Mongo user group.

The original bug report of https://jira.mongodb.org/browse/SERVER-6144 looks completely reasonable to me:

Original Title: dividing by zero makes field disappear
ExpressionDivide returns Undefined on divide by zero, which causes the field to be dropped. Might be more appropriate to return +/- Infinity or NaN.

However, I don't understand the reasoning behind how it got fixed. To me, the behaviour that was apparently there before https://jira.mongodb.org/browse/SERVER-6144 got fixed looks a lot better than how it behaves now: before the fix the query didn't crash, it merely returned values that could be slightly improved (from undefined to NaN and +/- infinity).

Comment by Mark Agarunov [ 09/Jun/17 ]

Hello rintcius,

Thank you for the report. Looking over the behavior you've described, this appears to be working as designed. Due to the changes listed in SERVER-6144, any division by 0 will result in a uassert.

Please note that SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-user group.

Thanks,
Mark

Comment by Rintcius Blok [ 31/May/17 ]

(comment obsolete because formatting is now improved in "steps to reproduce" section)

Generated at Thu Feb 08 04:20:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.