Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-87730

Different field order after $project returned by SBE and classic engine

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • 200

      Script to reproduce:

      db.coll.drop();
      db.coll.insert({
          str: null,
          obj: {}
      });
      const project = {
          $project: {"str": "a", "obj.str": "b"}
      };
      const classicResult = db.coll.aggregate([{$_internalInhibitOptimization: {}}, project]).toArray();
      jsTestLog(classicResult);
      const sbeResult = db.coll.aggregate([project]).toArray();
      jsTestLog(sbeResult);
      

      Result:

      [jsTest] ----
      [jsTest] [
      [jsTest] 	{
      [jsTest] 		"_id" : ObjectId("65eb888b167f6208ab3a8e68"),
      [jsTest] 		"obj" : {
      [jsTest] 			"str" : "b"
      [jsTest] 		},
      [jsTest] 		"str" : "a"
      [jsTest] 	}
      [jsTest] ]
      [jsTest] ----
      
      
      [jsTest] ----
      [jsTest] [
      [jsTest] 	{
      [jsTest] 		"_id" : ObjectId("65eb888b167f6208ab3a8e68"),
      [jsTest] 		"str" : "a",
      [jsTest] 		"obj" : {
      [jsTest] 			"str" : "b"
      [jsTest] 		}
      [jsTest] 	}
      [jsTest] ]
      [jsTest] ----
      

            Assignee:
            andrew.paroski@mongodb.com Drew Paroski
            Reporter:
            rui.liu@mongodb.com Rui Liu
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: