summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Percy <david.percy@mongodb.com>2021-10-15 21:20:56 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-29 18:59:06 +0000
commit73b81b958fc245dcd72b55830868c63f07993b73 (patch)
tree05e7d52faf5782331b82a810ad50ed22cc1e0108 /src
parentcfff9eaf82fe360ab11cd3c527835f0576d429d7 (diff)
downloadmongo-73b81b958fc245dcd72b55830868c63f07993b73.tar.gz
SERVER-60762 Error when partitionBy is a constant array
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/pipeline/document_source_set_window_fields.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/document_source_set_window_fields.cpp b/src/mongo/db/pipeline/document_source_set_window_fields.cpp
index 7a9fe901c8f..0f15a20593f 100644
--- a/src/mongo/db/pipeline/document_source_set_window_fields.cpp
+++ b/src/mongo/db/pipeline/document_source_set_window_fields.cpp
@@ -182,8 +182,12 @@ list<intrusive_ptr<DocumentSource>> document_source_set_window_fields::create(
// which will bind the value of the expression to the name in simplePartitionBy.
if (partitionBy) {
partitionBy = (*partitionBy)->optimize();
- if (dynamic_cast<ExpressionConstant*>(partitionBy->get())) {
- // partitionBy optimizes to a constant expression, equivalent to a single partition.
+ if (auto exprConst = dynamic_cast<ExpressionConstant*>(partitionBy->get())) {
+ uassert(ErrorCodes::TypeMismatch,
+ "An expression used to partition cannot evaluate to value of type array",
+ !exprConst->getValue().isArray());
+ // Partitioning by a constant, non-array expression is equivalent to not partitioning
+ // (putting everything in the same partition).
} else if (auto exprFieldPath = dynamic_cast<ExpressionFieldPath*>(partitionBy->get());
exprFieldPath && !exprFieldPath->isVariableReference()) {
// ExpressionFieldPath has "CURRENT" as an explicit first component,