Provide Dependency Graph API for collection field output alias resolution

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The Join ordering project needs to be able to map the foreignField name to the name at the output of the subpipeline.

      Example from alya.berciu@mongodb.com:

      [
                  {$lookup: {from: "A", localField: "a", foreignField: "b", as: "fromA", pipeline: [
                      {$project: {renamedField: "$b"}}
                  ]}},
                  {$unwind: "$fromA"}
      ]
      

      When they detect that the foreignField "b" is not present in the output, they want to check if it is present under a different name, in this case "renamedField".

      We can do this efficiently in the dependency graph, using the _collectionAlias side-table.

      Proposed API

      // returns the path under which the 'baseDocumentField' field is aliased and visible to 'stage'
      // tie-breaks deterministically when multiple aliases are present (not specified which one is returned).
      optional<string> getBaseDocumentFieldAlias(
          DocumentSource* stage, PathRef baseDocumentField)
      

            Assignee:
            Vesko Karaganev
            Reporter:
            Vesko Karaganev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: