summaryrefslogtreecommitdiff
path: root/jstests/aggregation/sources/setWindowFields/comprehensive_parse.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/aggregation/sources/setWindowFields/comprehensive_parse.js')
-rw-r--r--jstests/aggregation/sources/setWindowFields/comprehensive_parse.js51
1 files changed, 17 insertions, 34 deletions
diff --git a/jstests/aggregation/sources/setWindowFields/comprehensive_parse.js b/jstests/aggregation/sources/setWindowFields/comprehensive_parse.js
index 4dd4cc90565..dbe509e2c59 100644
--- a/jstests/aggregation/sources/setWindowFields/comprehensive_parse.js
+++ b/jstests/aggregation/sources/setWindowFields/comprehensive_parse.js
@@ -65,7 +65,6 @@ const windows = {
// The list of sort definitions to test.
const sortBys = {
none: null,
- expr: {partitionSeq: {$meta: "randVal"}},
asc: {partitionSeq: 1},
desc: {partitionSeq: -1},
asc_date: {date: 1},
@@ -105,11 +104,18 @@ function constructQuery(wf, window, sortBy, partitionBy) {
}
// Given an element of each of the lists above, what is the expected
-// result. The output should be 'OK' or the expected integer
+// result. The output should be 'SKIP', 'OK' or the expected integer
// error code.
function expectedResult(wfType, windowType, sortType, partitionType) {
// Static errors all come first.
+ // Skip range windows over dates or that are over descending windows.
+ if (windowType.endsWith('range')) {
+ if (sortType.endsWith('date') || sortType.startsWith('desc')) {
+ return 'SKIP';
+ }
+ }
+
// Derivative and integral require an ascending sort
// and an explicit window.
if (wfType.startsWith('derivative')) {
@@ -123,11 +129,6 @@ function expectedResult(wfType, windowType, sortType, partitionType) {
return ErrorCodes.FailedToParse;
}
- // '$derivative requires a non-expression sortBy'.
- if (sortType == "expr") {
- return ErrorCodes.FailedToParse;
- }
-
} else if (wfType.startsWith('integral')) {
// Integral requires a sort.
if (sortType == 'none') {
@@ -139,11 +140,6 @@ function expectedResult(wfType, windowType, sortType, partitionType) {
return ErrorCodes.FailedToParse;
}
- // '$integral requires a non-expression sortBy'.
- if (sortType == "expr") {
- return ErrorCodes.FailedToParse;
- }
-
} else if (wfType.startsWith('expMovingAvg')) {
// $expMovingAvg doesn't accept a window.
if (windowType != 'none') {
@@ -183,23 +179,9 @@ function expectedResult(wfType, windowType, sortType, partitionType) {
}
// Range based windows require a sort over a single field.
- if (windowType.endsWith('range')) {
- if (sortType == 'none' || sortType == 'multi') {
- // 'Range-based window require sortBy a single field'.
- return 5339902;
- }
- if (sortType == 'expr') {
- // 'Range-based bounds require a non-expression sortBy'
- return 8947400;
- }
- if (sortType.startsWith('desc')) {
- // 'Range-based bounds require an ascending sortBy'.
- return 8947401;
- }
- if (sortType.endsWith('date') && !partitionType.endsWith('array')) {
- // 'For windows that involve date or time ranges, a unit must be provided.'
- return 5429413;
- }
+ if (windowType.endsWith('range') && (sortType == 'none' || sortType == 'multi')) {
+ // 'Range-based window require sortBy a single field'.
+ return 5339902;
}
if (partitionType === 'static_array') {
@@ -256,6 +238,10 @@ function* makeTests() {
expectedResult: expectedResult(wfType, windowType, sortType, partitionType)
};
+ if (test.expectedResult == 'SKIP') {
+ continue;
+ }
+
yield test;
}
}
@@ -265,16 +251,13 @@ function* makeTests() {
// Run all the combinations generated in makeTests.
for (const test of makeTests()) {
- const errorMsg = "Command was: " + tojson(test.query);
if (test.expectedResult == ErrorCodes.OK) {
assert.commandWorked(
- coll.runCommand({aggregate: coll.getName(), pipeline: [test.query], cursor: {}}),
- errorMsg);
+ coll.runCommand({aggregate: coll.getName(), pipeline: [test.query], cursor: {}}));
} else {
assert.commandFailedWithCode(
coll.runCommand({aggregate: coll.getName(), pipeline: [test.query], cursor: {}}),
- test.expectedResult,
- errorMsg);
+ test.expectedResult);
}
}
})();