Info
When running an aggregation pipeline that includes a $unionWith or $lookup stage to a timeseries collection, specifying a collation that is different than the timeseries collection's collation causes an error to be thrown:
MongoServerError: Cannot override a view's default collation
If the collation of the timeseries collection and the specified collation of the aggregation are the same, then the aggregation succeeds.
There was a similar issue where performing an aggregation on a timeseries collection and specifying a non-default collation caused the same error to be thrown, but that was fixed: https://jira.mongodb.org/browse/SERVER-54597. The issue of specifying a non-default collation when a unionWith/lookup stage to a timeseries collection is involved still remains.
Top User Comments
JIRAUSER1265262 commented on Tue, 20 Jun 2023 15:04:20 +0000:
Hi kristin.dorgelo@vertigis.com!
Thanks for your descriptive report! I'm going to pass this on to a relevant team to take a look.
Christopher
Steps to Reproduce
Create collections.
db.createCollection('ts', {timeseries: {timeField: 'ts', metaField: 'meta'}});
db.createCollection('test');
This command succeeds after bug SERVER-54597 was fixed.
db.ts.aggregate([{$project: {'meta.field1': 1}}], {collation: {locale: 'en'}});
This command succeeds as the collation is the same as the timeseries collation.
db.test.aggregate([{$unionWith: {coll: 'ts', pipeline: [{$project: {'meta.field1': 1}}]}}], {collation: {locale: 'simple'}});
This command throws an error as the collation is different than the timeseries collation.
db.test.aggregate([{$unionWith: {coll: 'ts', pipeline: [{$project: {'meta.field1': 1}}]}}], {collation: {locale: 'en'}});