summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorauto-revert-processor <dev-prod-dag@mongodb.com>2021-09-23 00:14:41 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-23 00:53:17 +0000
commitfc885a164c0595624d9b50b9d950880414777781 (patch)
tree924899afa4d01bbb893ac37f2585551a857ee5da
parent4ae62e32c166d8483992ff49d53c00d238ba1aea (diff)
downloadmongo-fc885a164c0595624d9b50b9d950880414777781.tar.gz
Revert "SERVER-51592 Added support for anyElementTrue in SBE"
This reverts commit 130476fc56a711b489525112c855766bd2a1bb23.
-rw-r--r--jstests/aggregation/expressions/any_element_true.js30
-rw-r--r--src/mongo/db/pipeline/expression.h8
-rw-r--r--src/mongo/db/query/sbe_stage_builder_expression.cpp35
-rw-r--r--src/mongo/db/query/sbe_stage_builder_helpers.h4
4 files changed, 9 insertions, 68 deletions
diff --git a/jstests/aggregation/expressions/any_element_true.js b/jstests/aggregation/expressions/any_element_true.js
index 324bdd7d87c..4682ee6d858 100644
--- a/jstests/aggregation/expressions/any_element_true.js
+++ b/jstests/aggregation/expressions/any_element_true.js
@@ -5,18 +5,8 @@
load("jstests/libs/sbe_assert_error_override.js"); // Override error-code-checking APIs.
const coll = db.any_element_true;
coll.drop();
-assert.commandWorked(coll.insert({
- _id: 0,
- allTrue: [true, true],
- someTrue: [true, false],
- noneTrue: [0, false],
- nonArray: 1,
- nullInput: [null],
- undefinedInput: [undefined],
- undefinedTrue: [undefined, true],
- nullTrue: [null, true],
- empty: []
-}));
+assert.commandWorked(
+ coll.insert({_id: 0, allTrue: [true, true], someTrue: [true, false], noneTrue: [0, false]}));
function testOp(expression, expected) {
const results = coll.aggregate([{$project: {_id: 0, result: expression}}]).toArray();
@@ -26,12 +16,6 @@ function testOp(expression, expected) {
assert.eq(loneResult.result, expected, loneResult);
}
-function assertThrows(expression) {
- const error =
- assert.throws(() => coll.aggregate([{$project: {_id: 0, result: expression}}]).toArray());
- assert.commandFailedWithCode(error, 5159200);
-}
-
testOp({$anyElementTrue: {$literal: [true, true]}}, true);
testOp({$anyElementTrue: {$literal: [1, true]}}, true);
testOp({$anyElementTrue: {$literal: [true, 0]}}, true);
@@ -40,14 +24,4 @@ testOp({$anyElementTrue: {$literal: [false, 0, false]}}, false);
testOp({$anyElementTrue: "$allTrue"}, true);
testOp({$anyElementTrue: "$someTrue"}, true);
testOp({$anyElementTrue: "$noneTrue"}, false);
-testOp({$anyElementTrue: ["$noneTrue"]}, false);
-testOp({$anyElementTrue: [["$non_existent_field"]]}, false);
-testOp({$anyElementTrue: [["$non_existent_field", true]]}, true);
-testOp({$anyElementTrue: "$nullInput"}, false);
-testOp({$anyElementTrue: "$undefinedInput"}, false);
-testOp({$anyElementTrue: "$undefinedTrue"}, true);
-testOp({$anyElementTrue: "$nullTrue"}, true);
-testOp({$anyElementTrue: "$empty"}, false);
-assertThrows({$anyElementTrue: "$nonArray"});
-assertThrows({$anyElementTrue: ["$non_existent_field"]});
}());
diff --git a/src/mongo/db/pipeline/expression.h b/src/mongo/db/pipeline/expression.h
index 40bc488771d..f696152ec59 100644
--- a/src/mongo/db/pipeline/expression.h
+++ b/src/mongo/db/pipeline/expression.h
@@ -1001,9 +1001,13 @@ public:
class ExpressionAnyElementTrue final : public ExpressionFixedArity<ExpressionAnyElementTrue, 1> {
public:
explicit ExpressionAnyElementTrue(ExpressionContext* const expCtx)
- : ExpressionFixedArity<ExpressionAnyElementTrue, 1>(expCtx) {}
+ : ExpressionFixedArity<ExpressionAnyElementTrue, 1>(expCtx) {
+ expCtx->sbeCompatible = false;
+ }
ExpressionAnyElementTrue(ExpressionContext* const expCtx, ExpressionVector&& children)
- : ExpressionFixedArity<ExpressionAnyElementTrue, 1>(expCtx, std::move(children)) {}
+ : ExpressionFixedArity<ExpressionAnyElementTrue, 1>(expCtx, std::move(children)) {
+ expCtx->sbeCompatible = false;
+ }
Value evaluate(const Document& root, Variables* variables) const final;
const char* getOpName() const final;
diff --git a/src/mongo/db/query/sbe_stage_builder_expression.cpp b/src/mongo/db/query/sbe_stage_builder_expression.cpp
index 90dee12759a..4e25a8e18a9 100644
--- a/src/mongo/db/query/sbe_stage_builder_expression.cpp
+++ b/src/mongo/db/query/sbe_stage_builder_expression.cpp
@@ -849,40 +849,7 @@ public:
visitMultiBranchLogicExpression(expr, sbe::EPrimBinary::logicAnd);
}
void visit(const ExpressionAnyElementTrue* expr) final {
- auto [inputSlot, stage] = projectEvalExpr(_context->popEvalExpr(),
- _context->extractCurrentEvalStage(),
- _context->planNodeId,
- _context->state.slotIdGenerator);
-
- auto fromBranch = makeFilter<false>(
- std::move(stage),
- makeBinaryOp(sbe::EPrimBinary::logicOr,
- makeFillEmptyFalse(makeFunction("isArray", makeVariable(inputSlot))),
- makeFail(5159200, "$anyElementTrue's argument must be an array")),
- _context->planNodeId);
-
- auto innerOutputSlot = _context->state.slotId();
- auto innerBranch = makeProject(makeLimitCoScanStage(_context->planNodeId),
- _context->planNodeId,
- innerOutputSlot,
- generateCoerceToBoolExpression(inputSlot));
-
- auto traverseSlot = _context->state.slotId();
- auto traverseStage = makeTraverse(std::move(fromBranch),
- std::move(innerBranch),
- inputSlot,
- traverseSlot,
- innerOutputSlot,
- makeBinaryOp(sbe::EPrimBinary::logicOr,
- makeVariable(traverseSlot),
- makeVariable(innerOutputSlot)),
- makeVariable(traverseSlot),
- _context->planNodeId,
- 1,
- _context->getLexicalEnvironment());
-
- _context->pushExpr(makeFillEmptyFalse(makeVariable(traverseSlot)),
- std::move(traverseStage));
+ unsupportedExpression(expr->getOpName());
}
void visit(const ExpressionArray* expr) final {
unsupportedExpression(expr->getOpName());
diff --git a/src/mongo/db/query/sbe_stage_builder_helpers.h b/src/mongo/db/query/sbe_stage_builder_helpers.h
index 46f41471ac0..c5a63a3b002 100644
--- a/src/mongo/db/query/sbe_stage_builder_helpers.h
+++ b/src/mongo/db/query/sbe_stage_builder_helpers.h
@@ -216,10 +216,6 @@ std::unique_ptr<sbe::EExpression> makeVariable(sbe::value::SlotId slotId);
std::unique_ptr<sbe::EExpression> makeVariable(sbe::FrameId frameId, sbe::value::SlotId slotId);
-inline auto makeFail(int code, StringData errorMessage) {
- return sbe::makeE<sbe::EFail>(ErrorCodes::Error{code}, errorMessage);
-}
-
/**
* Check if expression returns Nothing and return null if so. Otherwise, return the expression.
*/