jstests/core/cover_null_queries.js
/**
 * Validates that the explain() of command 'cmdObj' has the stages in 'expectedStages'.
 *
 * The field 'expectedStages' should be specified as an object with keys matching the stages
 * expected in the explain output and values indicating how many times each stage should be expected
 * to appear in the output (useful to verify if there are two COUNT_SCANS or that there are 0
 * IX_SCANS, for example).
 *
 * The field 'isAgg' is a boolean indicating whether or not the command is an aggregation.
 */
Validates that the explain() of command 'cmdObj' has the stages in 'expectedStages'.
The field 'expectedStages' should be specified as an object with keys matching the stages
expected in the explain output and values indicating how many times each stage should be expected
to appear in the output (useful to verify if there are two COUNT_SCANS or that there are 0
IX_SCANS, for example).

The field 'isAgg' is a boolean indicating whether or not the command is an aggregation.
Validates that the explain () of command ' cmdObj ' has the stages in ' expectedStages ' . The field ' expectedStages ' should be specified as an object with keys matching the stages expected in the explain output and values indicating how many times each stage should be expected to appear in the output ( useful to verify if there are two COUNT_SCANS or that there are 0 IX_SCANS for example ) . The field ' isAgg ' is a boolean indicating whether or not the command is an aggregation .
function validateStages({cmdObj, expectedStages, isAgg}) {
    const explainObj = assert.commandWorked(coll.runCommand({explain: cmdObj}));
    for (const [expectedStage, count] of Object.entries(expectedStages)) {
        const planStages = isAgg
            ? getAggPlanStages(explainObj, expectedStage,  true)
            : getPlanStages(explainObj, expectedStage);
        assert.eq(planStages.length, count, {foundStages: planStages, explain: explainObj});
        if (count > 0) {
            for (const planStage of planStages) {
                assert.eq(planStage.stage, expectedStage, planStage);
            }
        }
    }
}
function validateStages ( { cmdObj , expectedStages , isAgg } ) { const explainObj = assert . commandWorked ( coll . runCommand ( { explain : cmdObj } ) ) ; for ( const [ expectedStage , count ] of Object . entries ( expectedStages ) ) { const planStages = isAgg ? getAggPlanStages ( explainObj , expectedStage , true ) : getPlanStages ( explainObj , expectedStage ) ; assert . eq ( planStages . length , count , { foundStages : planStages , explain : explainObj } ) ; if ( count > 0 ) { for ( const planStage of planStages ) { assert . eq ( planStage . stage , expectedStage , planStage ) ; } } } }
Validates that the explain() of command 'cmdObj' has the stages in 'expectedStages'.
Validates that the explain () of command ' cmdObj ' has the stages in ' expectedStages ' .
/* useQueryPlannerSection */