[COMPASS-5567] Incorrect shell aggregation syntax in transpiler test Created: 07/Mar/22  Updated: 10/Aug/22

Status: Open
Project: Compass
Component/s: Aggregation pipeline, Embedded Shell
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Patrick Freed Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Problem Statement/Rationale

The translation of an aggregation using the mongo shell appears incorrect. It provides the following example syntax for an aggregation:

mongo 'mongodb://localhost:27017' --eval "db = db.getSiblingDB('db');
db.collection.aggregate({                                            
  'x': new NumberLong(0),                                            
  'y': new ObjectId()                                                
});"                                                                 

Aggregation should be using a pipeline represented as an array though. Also, this needs the $match stage (assuming this is meant to be a filter).

Actually executing this yields the following error:

uncaught exception: Error: command failed: {
	"ok" : 0,
	"errmsg" : "A pipeline stage specification object must contain exactly one field.",
	"code" : 40323,
	"codeName" : "Location40323"
} : aggregate failed :

Additional Notes

While this ticket only covers the shell, the other examples look like they might have the same issue, since none of them specify $match or use arrays for the pipeline. I haven't personally tested them yet though.

More broadly speaking, it seems like we might want to consider running integration tests using the generated output to ensure they're correct.



 Comments   
Comment by Maurizio Casimirri [ 10/Jun/22 ]

Yeah this seems to be the case, we could adjust the inputs. Worth noting that with the current architecture of bson-transpilers that case is actually legit, there is no explicit separation between aggregations and anything else, is just implicitly intended as such, and any input can be transformed. Is probably still worth adjusting those tests.

Generated at Wed Feb 07 22:40:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.