diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-18 17:02:53 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-18 17:02:53 -0300 |
| commit | 959575a5ca598bf5f37fb5cebe7ed1d80d3d71f7 (patch) | |
| tree | acc8d60aedb12b70048e676e8a7349deb0010db8 /src/mongo/db/query/planner_ixselect_test.cpp | |
| parent | 76588293975fc059cf076779e4283e6ffaf8afff (diff) | |
New upstream version 6.0.20upstream
Diffstat (limited to 'src/mongo/db/query/planner_ixselect_test.cpp')
| -rw-r--r-- | src/mongo/db/query/planner_ixselect_test.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mongo/db/query/planner_ixselect_test.cpp b/src/mongo/db/query/planner_ixselect_test.cpp index 1df4d714e67..2507e65ce56 100644 --- a/src/mongo/db/query/planner_ixselect_test.cpp +++ b/src/mongo/db/query/planner_ixselect_test.cpp @@ -1333,6 +1333,45 @@ TEST(QueryPlannerIXSelectTest, HashedSparseIndexShouldBeRelevantForExistsTrue) { testRateIndices("{a: {$exists: true}}", "", kSimpleCollator, {entry}, "a", expectedIndices); } +TEST(QueryPlannerIXSelectTest, GeoPredicateCanOnlyUse2dsphereIndex) { + std::vector<IndexEntry> indices; + auto btreeEntry = buildSimpleIndexEntry(BSON("loc" << 1)); + auto twodSphereEntry = buildSimpleIndexEntry(BSON("loc" + << "2dsphere")); + indices.push_back(btreeEntry); + indices.push_back(twodSphereEntry); + std::set<size_t> expectedIndices = {1}; + testRateIndices(R"({loc: {$geoWithin: {$geometry: {type: 'Polygon', + coordinates: [[[0,0],[0,1],[1,0],[0,0]]]}}}})", + "", + kSimpleCollator, + indices, + "loc", + expectedIndices); +} + +TEST(QueryPlannerIXSelectTest, GeoPredicateWithNotCanOnlyUse2dsphereIndex) { + std::vector<IndexEntry> indices; + auto btreeEntry = buildSimpleIndexEntry(BSON("loc" << 1)); + auto twodSphereEntry = buildSimpleIndexEntry(BSON("loc" + << "2dsphere")); + indices.push_back(btreeEntry); + indices.push_back(twodSphereEntry); + // This query gets parsed to {$not: {$and: {$geoWithin: <>}}} and then tags + // the 2dsphere index as relevant. If the $and is optimized away ({$not: {$geoWithin: <>}}), + // that tagging is skipped. + // TODO SERVER-92427: The tagging behavior should be made consistent so that this query has no + // expectedIndices. + std::set<size_t> expectedIndices = {1}; + testRateIndices(R"({loc: {$not: {$geoWithin: {$geometry: {type: 'Polygon', + coordinates: [[[0,0],[0,1],[1,0],[0,0]]]}}}}})", + "", + kSimpleCollator, + indices, + "loc", + expectedIndices); +} + /* * Will compare 'keyPatterns' with 'entries'. As part of comparing, it will sort both of them. */ |
