[SERVER-45247] Introduce an extended JSON output mode for mqlrun Created: 19/Dec/19  Updated: 06/Dec/22

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

Type: Improvement Priority: Minor - P4
Reporter: David Storch Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: neweng, qexec-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Participants:

 Description   

The mqlrun tool (which is not shipped for consumption by users) currently supports a "-j" flag, which causes the query results to be printed to the standard output as relaxed JSON:

➜  mqlrun -j -e '[{$limit: 1}]' src/mongo/db/modules/enterprise/jstests/mqlrun/ny_phone_sales.bson
{ _id: ObjectId('5bd761dcae323e45a93ccff8'), saleDate: new Date(1377077767188), items: [ { name: "envelopes", tags: [ "stationary", "office", "general" ], price: 6.5, quantity: 5 }, { name: "notepad", tags: [ "office", "writing", "school" ], price: 8.11, quantity: 3 }, { name: "backpack", tags: [ "school", "travel", "kids" ], price: 150.18, quantity: 4 }, { name: "notepad", tags: [ "office", "writing", "school" ], price: 5.65, quantity: 1 }, { name: "pens", tags: [ "writing", "office", "school", "stationary" ], price: 28.24, quantity: 5 }, { name: "binder", tags: [ "school", "general", "organization" ], price: 14.64, quantity: 6 }, { name: "notepad", tags: [ "office", "writing", "school" ], price: 11.91, quantity: 5 }, { name: "laptop", tags: [ "electronics", "school", "office" ], price: 896.67, quantity: 3 }, { name: "binder", tags: [ "school", "general", "organization" ], price: 15.56, quantity: 4 } ], storeLocation: "New York", customer: { gender: "F", age: 53, email: "se@nacwev.an", satisfaction: 4 }, couponUsed: false, purchaseMethod: "Phone" }

This JSON is "relaxed" in that there are no quotes around property names. There are also stringifications of BSON types that don't exist in real JSON, such as dates.

We should add an output mode in which mqlrun produces canonical mode extended JSON. This output will be real JSON that can be parsed by any third-party JSON parser. There is also a well-defined lossless conversion between extended JSON and BSON, so this output mode will ensure that the original BSON can be exactly recovered using an extended JSON parser. This could be useful for testing scenarios, where we need to make exact assertions about the result set, but we also want the results to be human-readable.


Generated at Thu Feb 08 05:08:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.