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

[CQF] Order of fields in output documents of simple inclusion projection queries is not the same in CQF vs SBE

    • Type: Icon: Task Task
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization

      Order of fields in output documents of simple inclusion projection queries is not the same in CQF vs SBE.

      Consider the following documents:

      { “_id” : 0, “a1" : { “b1” : 1, “c1" : 1 }, “a2” : { “b2" : 1, “c2” : 1 } }
      { “_id” : 1, “a2” : { “c2" : 1, “b2” : 1 }, “a1" : { “c1” : 1, “b1" : 1 } }
      

      and the query

      {$project: {‘a2.b2’: 1, ‘a1.b1’: 1}}
      

      SBE orders the fields by the order in which they were included in the projection spec, so in both output docs we see "a2" followed by "a1". CQF orders the fields alphabetically, so in both output docs we see "a1" followed be "a2".

      Classic does something else; it maintains the order of the fields in the input document. The classic/SBE difference seemed to be approved.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            hana.pearlman@mongodb.com Hana Pearlman
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: