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

View resolution error on sharded view with $unionWith in explain

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.0.0-rc12
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • Fully Compatible
    • ALL
    • v8.0
    • Hide

      Run the following test case in sharded_collections_jscore_passthrough suite

      const coll = assertDropAndRecreateCollection(db, jsTestName());
      const viewName = "identityView";
      assertDropCollection(db, viewName);
      assert.commandWorked(db.createView(viewName, coll.getName(), []));
      
      const secondaryColl = assertDropAndRecreateCollection(db, "secondary");
      const secondaryViewName = "secondaryIdentityView";
      assertDropCollection(db, secondaryViewName);
      assert.commandWorked(db.createView(secondaryViewName, secondaryColl.getName(), []));
      
      // Works just fine.
      jsTestLog(coll.aggregate([
              {$match: {a: 1, b: 5}},
              {$unionWith: {coll: secondaryViewName, pipeline: [{$match: {a: 1, b: 5}}]}}
          ]
      ).toArray());
      
      // Fails to resolve the view.
      jsTestLog(coll.explain().aggregate([
              {$match: {a: 1, b: 5}},
              {$unionWith: {coll: secondaryViewName, pipeline: [{$match: {a: 1, b: 5}}]}}
          ]
      ));
      
      Show
      Run the following test case in sharded_collections_jscore_passthrough suite const coll = assertDropAndRecreateCollection(db, jsTestName()); const viewName = "identityView" ; assertDropCollection(db, viewName); assert.commandWorked(db.createView(viewName, coll.getName(), [])); const secondaryColl = assertDropAndRecreateCollection(db, "secondary" ); const secondaryViewName = "secondaryIdentityView" ; assertDropCollection(db, secondaryViewName); assert.commandWorked(db.createView(secondaryViewName, secondaryColl.getName(), [])); // Works just fine. jsTestLog(coll.aggregate([         {$match: {a: 1, b: 5}},         {$unionWith: {coll: secondaryViewName, pipeline: [{$match: {a: 1, b: 5}}]}}     ] ).toArray()); // Fails to resolve the view. jsTestLog(coll.explain().aggregate([ {$match: {a: 1, b: 5}}, {$unionWith: {coll: secondaryViewName, pipeline: [{$match: {a: 1, b: 5}}]}} ] ));
    • QO 2024-04-29, QO 2024-05-13, QO 2024-05-27, QO 2024-06-10, QO 2024-06-24, QO 2024-07-08, QO 2024-07-22

      View resolution for views used in $unionWith pipelines is not resolved correctly in explain, however, it seems to be working just fine when running a regular aggregate

            Assignee:
            henri.nikku@mongodb.com Henri Nikku
            Reporter:
            denis.grebennicov@mongodb.com Denis Grebennicov
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: