diff options
author | Jennifer Peshansky <jennifer.peshansky@mongodb.com> | 2021-08-19 20:39:54 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-08-25 18:23:17 +0000 |
commit | 7d58a3a7d1f1a8766c6f289f21ebd977385c4252 (patch) | |
tree | d41cf71b7844d77d7ec7432cba125239ec4907aa | |
parent | 3820bd5558ccc46958cba972676501c1e9b56330 (diff) | |
download | mongo-7d58a3a7d1f1a8766c6f289f21ebd977385c4252.tar.gz |
SERVER-59103 Wrap 'stage' in a stageOrLimitCoScan call to prevent a null stage being passed and add test coverage.
-rw-r--r-- | jstests/aggregation/expressions/concat_arrays.js | 5 | ||||
-rw-r--r-- | src/mongo/db/query/sbe_stage_builder_helpers.cpp | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/jstests/aggregation/expressions/concat_arrays.js b/jstests/aggregation/expressions/concat_arrays.js index 37f4b6c4a72..924e9037efc 100644 --- a/jstests/aggregation/expressions/concat_arrays.js +++ b/jstests/aggregation/expressions/concat_arrays.js @@ -75,6 +75,11 @@ runAndAssert(["$str_arr", {$filter: {input: "$int_arr", ] }}}, "$int_arr"], [["a", "b", "c", 2, 3, 1, 2, 3, 4]]); +// Confirm that empty arrays can be concatenated with variables. +runAndAssert( + ["$str_arr", {$filter: {input: [], cond: {$isArray: [{$concatArrays: [[], "$$this"]}]}}}], + [["a", "b", "c"]]); + // Confirm that having any combination of null or missing inputs and valid inputs produces null. runAndAssertNull(["$int_arr", "$null_val"]); runAndAssertNull(["$int_arr", null]); diff --git a/src/mongo/db/query/sbe_stage_builder_helpers.cpp b/src/mongo/db/query/sbe_stage_builder_helpers.cpp index 80fcdf7df0b..71015bef45f 100644 --- a/src/mongo/db/query/sbe_stage_builder_helpers.cpp +++ b/src/mongo/db/query/sbe_stage_builder_helpers.cpp @@ -311,7 +311,7 @@ std::pair<sbe::value::SlotId, EvalStage> projectEvalExpr( sbe::value::SlotIdGenerator* slotIdGenerator) { // If expr's value is already in a slot, return the slot. if (expr.getSlot()) { - return {*expr.getSlot(), std::move(stage)}; + return {*expr.getSlot(), stageOrLimitCoScan(std::move(stage), planNodeId)}; } // If expr's value is an expression, create a ProjectStage to evaluate the expression |