[SERVER-27762] creating a view without specifying collation explicitly should insert the collation of the underlying entity Created: 19/Jan/17  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Querying
Affects Version/s: 3.4.1
Fix Version/s: None

Type: Improvement Priority: Critical - P2
Reporter: Asya Kamsky Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: QFB, asya, query-44-grooming, read-only-views
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-35314 Allow changing default collation for ... Backlog
is related to SERVER-55653 Queries on time-series views do not a... Closed
Assigned Teams:
Query Optimization
Participants:
Case:

 Description   

Currently when collation is not explicitly specified in the createView command, we create the view with default collation (if it's on top of a collection) or error (if it's on top of a view).

Neither of these is very user friendly - when creating a view on top of a view, you should not need to explicitly specify identical collation to allow view definition to succeed - it should do the "logical" thing if collation is omitted - the only allowed behavior, which is to insert identical collation from the underlying view.

For view on a collection, I would argue that the default behavior should be the same - if explicit collation is not specified, it is extremely unlikely (nearly impossible) that what the user wants is "simple" collation, if the underlying collection has some other collation explicitly defined.

Therefore explicitly inserting collation of the underlying entity is the correct behavior.

I would suggest that already created views should of course retain their currently present behavior/attribute/collations, i.e. they will replicate exactly as they are, but newly created views will cause an explicit collation to be inserted in the entry for creating this view.



 Comments   
Comment by Asya Kamsky [ 10/Aug/17 ]

Imagine this workflow:

// foo has collation other than simple
db.foo.aggregate( [ <my-pipeline> ] )
// examine results, make sure they look correct
db.createView("viewname", "foo", [ <my-pipeline> ])
db.viewname.find()
// different results than what I just saw in my test!

Generated at Thu Feb 08 04:16:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.