summaryrefslogtreecommitdiff
path: root/src/mongo/s/query/cluster_aggregate.cpp
diff options
context:
space:
mode:
authorAdrian Gonzalez <adriangonzalezmontemayor@gmail.com>2022-10-07 02:14:09 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-07 03:13:43 +0000
commit0406b63884d9993f0eafd7d6dcd680e0ecdc1a1f (patch)
tree64af3e807ec0dcf7a65e31ad42f3db054b726e11 /src/mongo/s/query/cluster_aggregate.cpp
parent84e93642a6d7f52ae2df506cff0df2679f526a2c (diff)
downloadmongo-0406b63884d9993f0eafd7d6dcd680e0ecdc1a1f.tar.gz
SERVER-67598 Add support for maxSpanSeconds and roundingSeconds arguments
Diffstat (limited to 'src/mongo/s/query/cluster_aggregate.cpp')
-rw-r--r--src/mongo/s/query/cluster_aggregate.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/mongo/s/query/cluster_aggregate.cpp b/src/mongo/s/query/cluster_aggregate.cpp
index 807745b6caa..aad967a2a98 100644
--- a/src/mongo/s/query/cluster_aggregate.cpp
+++ b/src/mongo/s/query/cluster_aggregate.cpp
@@ -55,6 +55,7 @@
#include "mongo/db/query/explain_common.h"
#include "mongo/db/query/find_common.h"
#include "mongo/db/query/fle/server_rewrite.h"
+#include "mongo/db/timeseries/timeseries_gen.h"
#include "mongo/db/timeseries/timeseries_options.h"
#include "mongo/db/views/resolved_view.h"
#include "mongo/db/views/view.h"
@@ -234,9 +235,19 @@ void performValidationChecks(const OperationContext* opCtx,
* Rebuilds the pipeline and uses a different granularity value for the 'bucketMaxSpanSeconds' field
* in the $_internalUnpackBucket stage.
*/
-std::vector<BSONObj> rebuildPipelineWithTimeSeriesGranularity(const std::vector<BSONObj>& pipeline,
- BucketGranularityEnum granularity) {
- const auto bucketSpan = timeseries::getMaxSpanSecondsFromGranularity(granularity);
+std::vector<BSONObj> rebuildPipelineWithTimeSeriesGranularity(
+ const std::vector<BSONObj>& pipeline,
+ boost::optional<BucketGranularityEnum> granularity,
+ boost::optional<int32_t> maxSpanSeconds) {
+ int32_t bucketSpan = 0;
+
+ if (maxSpanSeconds) {
+ bucketSpan = *maxSpanSeconds;
+ } else {
+ bucketSpan = timeseries::getMaxSpanSecondsFromGranularity(
+ granularity.get_value_or(BucketGranularityEnum::Seconds));
+ }
+
std::vector<BSONObj> newPipeline;
for (auto& stage : pipeline) {
if (stage.firstElementFieldNameStringData() ==
@@ -579,7 +590,9 @@ Status ClusterAggregate::retryOnViewError(OperationContext* opCtx,
const auto& cm = executionNsRoutingInfoStatus.getValue();
if (cm.isSharded() && cm.getTimeseriesFields()) {
const auto patchedPipeline = rebuildPipelineWithTimeSeriesGranularity(
- resolvedAggRequest.getPipeline(), cm.getTimeseriesFields()->getGranularity());
+ resolvedAggRequest.getPipeline(),
+ cm.getTimeseriesFields()->getGranularity(),
+ cm.getTimeseriesFields()->getBucketMaxSpanSeconds());
resolvedAggRequest.setPipeline(patchedPipeline);
snapshotCm = cm;
}