Create alternative constructor for DocumentSourceUnionWith that directly takes in a Pipeline directly

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Won't Do
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Currently, the only way to make a DocumentSourceUnionWith with a specified pipeline is through DocumentSourceUnionWith::createWithBson which, of course, requires a BSON representation of the its sub-pipeline.

       

      Previously, this has been fine, but for $rankFusion, we discovered a case where its problematic to create a DocumentSourceUnionWith from BSON, given that we already have a parsed Pipeine object.

       

      We would like to add an additional DocumentSourceUnionWith constructor that can take in an already constructed Pipeline object. This will entail creating a new function with signature like:

      DocumentSourceUnionWith(
        const boost::intrusive_ptr<ExpressionContext>& expCtx,
        NamespaceString unionNss,   
        std::unique_ptr<Pipeline, PipelineDeleter> pipeline);

      The constructor implementation will look similar to the existing constructor that take the same argument, with the 'pipeline' as a std::vector<BSONObj>. Note you'll have to handle view resolution of the pipeline similar to how this constructor is (but not parse the pipeline). This will likely require copying over / similar logic to whats going on in buildPipelineFromViewDefinition / Pipeline::makePipelineFromViewDefinition.

       

      Once this constructor is created, you should figure out how to unit test it (if possible). It would probably be smart to install the constructor into $rankFusion desugaring directly and $scoreFusion in this PR, as the existing hybrid search jstests tests passing both on a collection an view will prove out the correctness of the new constructor.

              Assignee:
              Adithi Raghavan
              Reporter:
              Joe Shalabi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: