diff options
-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 |