summaryrefslogtreecommitdiff
path: root/jstests/aggregation/sources/multiple_unpack_bucket_error.js
blob: b00c6265f9bfc810ab798081a7a76ddce42fc155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
 * Tests that an aggregation pipeline cannot have more than one $_internalUnpackBucket stage.
 *
 * @tags: [ do_not_wrap_aggregations_in_facets ]
 */

(function() {
"use strict";

const coll = db.multiple_unpack_bucket_error;
coll.drop();

assert.commandFailedWithCode(db.runCommand({
    aggregate: coll.getName(),
    pipeline: [
        {
            $_internalUnpackBucket:
                {exclude: [], timeField: 'time', bucketMaxSpanSeconds: NumberInt(3600)}
        },
        {
            $_internalUnpackBucket:
                {exclude: [], timeField: 'time', bucketMaxSpanSeconds: NumberInt(3600)}
        }
    ],
    cursor: {}
}),
                             7183900);

// $_unpackBucket is an alias of $_internalUnpackBucket, the same restriction should apply.
assert.commandFailedWithCode(db.runCommand({
    aggregate: coll.getName(),
    pipeline: [
        {$_unpackBucket: {timeField: 'time'}},
        {
            $_internalUnpackBucket:
                {exclude: [], timeField: 'time', bucketMaxSpanSeconds: NumberInt(3600)}
        }
    ],
    cursor: {}
}),
                             7183900);
assert.commandFailedWithCode(db.runCommand({
    aggregate: coll.getName(),
    pipeline: [
        {
            $_internalUnpackBucket:
                {exclude: [], timeField: 'time', bucketMaxSpanSeconds: NumberInt(3600)}
        },
        {$_unpackBucket: {timeField: 'time'}}
    ],
    cursor: {}
}),
                             7183900);
assert.commandFailedWithCode(db.runCommand({
    aggregate: coll.getName(),
    pipeline: [{$_unpackBucket: {timeField: 'time'}}, {$_unpackBucket: {timeField: 'time'}}],
    cursor: {}
}),
                             7183900);
})();