Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-45247

Introduce an extended JSON output mode for mqlrun

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • Querying
    • Query Execution

    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.

      Attachments

        Activity

          People

            backlog-query-execution Backlog - Query Execution
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: