[SERVER-86373] Difference in behavior in SBE window fields implementation with classic in presence of NaN Created: 07/Feb/24  Updated: 08/Feb/24

Status: Needs Scheduling
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ian Boros Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Assigned Teams:
Query Execution
Operating System: ALL
Participants:
Linked BF Score: 146

 Description   

When using setWindowFields with a sortBy on a field that can be NaN, classic and SBE produce different results. Minimal repro:

(function() {                                                                                         
    const documentList = [                                                                            
        {_id: 0"num": 123}, // 0                                                                   
        {_id: 11"num": NaN }, // 3                                                                 
    ];                                                                                                
                                                                                                      
                                                                                                      
    for (let d of documentList) {                                                                     
        db.c.insert(d);                                                                               
    }                                                                                                 
                                                                                                      
    const aggPipe = [                                                                                 
        {$sort: {_id: 1}},                                                                            
         {$setWindowFields: {sortBy: {"num": 1},                                                      
                             output: {"test": {$min: "constant",                                      
                                               window: {range: ["current", 0]}}}}}                    
    ];                                                                                                
                                                                                                      
    //print("EXPLAIN: \n" +                                                                           
    //db.c.explain().aggregate(aggPipe).queryPlanner.winningPlan.slotBasedPlan.stages);               
                                                                                                      
    print("RESULTS: " + tojson(db.c.aggregate(aggPipe).toArray()));                                   
                                                                                                      
})();  

You can run this with:

python3 buildscripts/resmoke.py run --dbpathPrefix /home/ubuntu/data --installDir build/install/bin '--mongodSetParameters={internalQueryFrameworkControl: "trySbeEngine"}' --suites=core windowfields.js 

And compare to the results that 7.0 gives or that are given with internalQueryFrameworkControl=trySbeRestricted.


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