Update grouped_match_push_down.js for deep dotted-rename $match pushdown enabled by SERVER-128465

XMLWordPrintableJSON

    • Query Optimization
    • Fully Compatible
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      SERVER-128465 fixed the dependency graph so that dotted path modifications correctly apply array-traversal logic when computing arrayness. As part of that change, the prefixes of a $group compound key (e.g. _id, _id.c in {$group: {_id: {c: {d: "$d"}}}}) are now correctly recognized as freshly-constructed plain objects that can never be arrays — at any nesting depth.
       
      However, the ticket missed the noPassthrough test grouped_match_push_down.js failing on master:
       

      resmoke.py run --suites=no_passthrough
      grouped_match_push_down.js
      --mongodSetParameters='\{internalQueryFrameworkControl: forceClassicEngine}'
      

       
      The failing case asserts that a $match on a rename with a dotted path deeper than two levels is not pushed over the $group:
       

      [\{$group: {_id: {c: {d: "$d"}}, c: \{$sum: {$const: 1}}}},
      {$project: \{m: "$_id.c.d"}},
      {$match: \{m: {$eq: 2}}}]
      

       
      Expected stage sequence ["$cursor", "$group", "$project", "$match"] but got ["$cursor", "$group", "$project"] (the $match was pushed ahead of the $group and folded into the cursor).
       
      Root cause The old depth>2 restriction was a conservative limitation: the previous arrayness analysis could not prove that the deeper compound-key prefixes were non-array, so the optimizer refused to push the $match. With the SERVER-128465 fix, renamed ← _id.c.d ← $d is proven array-traversal-free, so the predicate is now correctly pushed before the $group (equivalent to {$match: {d: {$eq: 2}}}). This is the same optimization already validated for the single-level case (_id.c) and matches the unit-test change AvoidPushingMatchOverGroupWithLongDottedRename → MatchCanMoveAcrossLongDottedRenameOnGrouping in pipeline_test.cpp.
       
      The jstest was not part of the SERVER-128465 patch's test selection, so the stale expectation slipped through to master.
       
      Fix Update the deep-dotted-rename case in grouped_match_push_down.js to expect the $match to be pushed before the $group, across all three plan shapes:
       
      MultiStageClassic: ["$cursor", "$group", "$project"]
      MultiStageSBE: ["$cursor", "$project"]
      SingleStage: ["PROJECTION_DEFAULT", "GROUP", "COLLSCAN"]
      Query results are unchanged. Verified passing with both forceClassicEngine and the default engine.

            Assignee:
            Matt Olma
            Reporter:
            Matt Olma
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: