[SERVER-39336] In order to be schema friendly, $mod output should be based only on input types, not values Created: 01/Feb/19  Updated: 24/Jan/24  Resolved: 20/Nov/23

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Improvement Priority: Minor - P4
Reporter: Jacob Evans Assignee: James Harrison
Resolution: Fixed Votes: 0
Labels: greenerbuild, mql-semantics, qopt-team, query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by COMPASS-7471 Investigate changes in SERVER-39336: ... Closed
is depended on by TOOLS-3432 Investigate changes in SERVER-39336: ... Closed
Documented
is documented by DOCS-16507 Investigate changes in SERVER-39336: ... Closed
Problem/Incident
causes SERVER-84237 Incorrect $mod aggregation expression... Closed
Related
Assigned Teams:
Query Optimization
Backwards Compatibility: Minor Change
Participants:
Linked BF Score: 134

 Description   

$mod has a special condition if the right-hand-side is of non-integral type but of integral value.
https://github.com/mongodb/mongo/blob/8387824b3ac937b0489fcb94c590cc663b47348c/src/mongo/db/pipeline/expression.cpp#L2528
We should eliminate this condition from the conditional so that the output type of an arithmetic expression is based only on input types, not values. This has two benefits:
It causes a pipeline to output documents that are closer to a fixed schema.
Non-deterministicly-ordered input to grouping stages will no longer cause output of arbitrary type. This will eliminate the linked agg fuzzer issue.



 Comments   
Comment by Githook User [ 20/Nov/23 ]

Author:

{'name': 'James Harrison', 'email': '00jamesh@gmail.com', 'username': 'jameseh96'}

Message: SERVER-39336: Make $mod return type depend only on input types
Branch: master
https://github.com/mongodb/mongo/commit/b5547d9829f94b1ccd29774bb839f84b5c4e1ff6

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