summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_planner_geo_test.cpp
diff options
context:
space:
mode:
authorsamontea <merciers.merciers@gmail.com>2021-09-03 03:47:50 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-03 04:11:52 +0000
commit8073eb74318bc75a69a98491eebd647f9cde0f55 (patch)
treed59c76a75f55d06d6b42ae20338c8f475e3d9e60 /src/mongo/db/query/query_planner_geo_test.cpp
parentaec3ea814683689780a122a4b95c8b23794e59e7 (diff)
downloadmongo-8073eb74318bc75a69a98491eebd647f9cde0f55.tar.gz
SERVER-58371 Allow $_internalBucketGeoWithin to scan 'bucket-2dsphere' index
Diffstat (limited to 'src/mongo/db/query/query_planner_geo_test.cpp')
-rw-r--r--src/mongo/db/query/query_planner_geo_test.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/mongo/db/query/query_planner_geo_test.cpp b/src/mongo/db/query/query_planner_geo_test.cpp
index 7028e4d57a7..6452f130042 100644
--- a/src/mongo/db/query/query_planner_geo_test.cpp
+++ b/src/mongo/db/query/query_planner_geo_test.cpp
@@ -1766,6 +1766,41 @@ TEST_F(QueryPlannerTest, 2dsphereNonNearWithInternalExprEqOverTrailingFieldMulti
"b: [['MinKey','MaxKey',true,true]]}}}}}");
}
+TEST_F(QueryPlannerTest, 2dsphereBucketWithInternalBucketGeoWithin) {
+ params.options = QueryPlannerParams::NO_TABLE_SCAN;
+ addIndex(BSON("data.a"
+ << "2dsphere_bucket"),
+ false);
+
+ runQuery(
+ fromjson("{$_internalBucketGeoWithin: {withinRegion: {$centerSphere: [[0, 0], 10]}, field: "
+ "\"a\"}}"));
+
+ // This query will generate complex bounds, so we relax the checks to make the test readable.
+ relaxBoundsCheckingToSubsetOnly();
+
+ assertNumSolutions(1U);
+ assertSolutionExists(
+ "{fetch: {filter: {$_internalBucketGeoWithin: {withinRegion: {$centerSphere: [[0,0],10]}, "
+ "field: 'a'}},"
+ "node: {ixscan: {pattern: {'data.a' : '2dsphere_bucket'}, filter: null, bounds:"
+ "{'data.a': []" // Complex, so leaving empty.
+ "}}}}}");
+}
+
+TEST_F(QueryPlannerTest, 2dsphereBucketWithInternalBucketGeoWithin2dGeneratesCollScan) {
+ params.options = QueryPlannerParams::NO_TABLE_SCAN;
+ addIndex(BSON("data.a"
+ << "2dsphere_bucket"),
+ false);
+
+ // This query should not produce bounds.
+ runInvalidQuery(
+ fromjson("{$_internalBucketGeoWithin: {withinRegion: {$center: [[0, 0], 10]}, field: "
+ "\"a\"}}"));
+ ASSERT_EQUALS(plannerStatus.code(), ErrorCodes::NoQueryExecutionPlans);
+}
+
TEST_F(QueryPlannerTest, 2dWithinPredicateOverTrailingFieldElemMatchMultikey) {
params.options = QueryPlannerParams::NO_TABLE_SCAN;