summaryrefslogtreecommitdiff
path: root/jstests/core
diff options
context:
space:
mode:
authorJustin Seyster <justin.seyster@mongodb.com>2023-01-03 18:18:32 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-01-04 23:25:55 +0000
commit67c5ecd1847fe92b871ef9e26d3fb35f7bf1d662 (patch)
tree9a15e1e615c5b42a9e4c1380157204578b477909 /jstests/core
parentd5b298034e0e96238fbb49dd009be5536f258bfa (diff)
downloadmongo-67c5ecd1847fe92b871ef9e26d3fb35f7bf1d662.tar.gz
SERVER-64334 Test that column store index handles path edge cases
Diffstat (limited to 'jstests/core')
-rw-r--r--jstests/core/columnstore_index_correctness.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/jstests/core/columnstore_index_correctness.js b/jstests/core/columnstore_index_correctness.js
index 1466324c98c..4f28432aa07 100644
--- a/jstests/core/columnstore_index_correctness.js
+++ b/jstests/core/columnstore_index_correctness.js
@@ -140,6 +140,42 @@ const coll = db.columnstore_index_correctness;
`Unexpected number of documents: ${tojson(findDocsWithID)}`);
})();
+(function testFieldsWithDotsAndDollars() {
+ const doc = {
+ _id: 1,
+ "._id": 2,
+ "": {"": 3},
+ ".": 4,
+ "a": {b: {c: 5}, "b.c": 6},
+ "$": 7,
+ "$a": 8,
+ "$$a": {"$.$": 9}
+ };
+ coll.drop();
+ assert.commandWorked(coll.insert(doc));
+ assert.commandWorked(coll.createIndex({"$**": "columnstore"}));
+
+ // Double check that the document was inserted correctly.
+ const queryResult = coll.findOne();
+ assert.docEq(queryResult, doc);
+
+ // A projection on "a.b.c" should retrieve {"a": {"b": {"c": 5}}} but _not_ {"a": {"b.c": 6}}.
+ const kProjection = {_id: 0, "a.b.c": 1};
+ const explain = coll.find({}, kProjection).explain();
+ assert(planHasStage(db, explain, "COLUMN_SCAN"),
+ "Projection of existing column " + tojson(explain));
+
+ const result = coll.findOne({}, kProjection);
+ assert.docEq(result, {a: {b: {c: 5}}});
+
+ // We cannot directly check the output of a column scan on most fields in the test document,
+ // because there is no way to express projections on fields with empty names, internal dots, or
+ // leading $s. For this test, we consider it sufficient that inserts to the column store do not
+ // crash or corrupt data.
+ const validationResult = assert.commandWorked(coll.validate({full: true}));
+ assert(validationResult.valid, validationResult);
+})();
+
// Multiple tests in this file use the same dataset. Intentionally not using _id as the unique
// identifier, to avoid getting IDHACK plans when we query by it.
const docs = [