summaryrefslogtreecommitdiff
path: root/jstests/cqf/type_predicate.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/cqf/type_predicate.js')
-rw-r--r--jstests/cqf/type_predicate.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/jstests/cqf/type_predicate.js b/jstests/cqf/type_predicate.js
new file mode 100644
index 00000000000..eb8de44b3f6
--- /dev/null
+++ b/jstests/cqf/type_predicate.js
@@ -0,0 +1,26 @@
+(function() {
+"use strict";
+
+load("jstests/libs/optimizer_utils.js"); // For checkCascadesOptimizerEnabled.
+if (!checkCascadesOptimizerEnabled(db)) {
+ jsTestLog("Skipping test because the optimizer is not enabled");
+ return;
+}
+
+const t = db.cqf_type_predicate;
+t.drop();
+
+for (let i = 0; i < 10; i++) {
+ assert.commandWorked(t.insert({a: i}));
+ assert.commandWorked(t.insert({a: i.toString()}));
+}
+
+{
+ const res = t.explain("executionStats").aggregate([{$match: {a: {$type: "string"}}}]);
+ assert.eq(10, res.executionStats.nReturned);
+}
+{
+ const res = t.explain("executionStats").aggregate([{$match: {a: {$type: "double"}}}]);
+ assert.eq(10, res.executionStats.nReturned);
+}
+}()); \ No newline at end of file