Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JSON CLI output format #878

Merged
merged 2 commits into from Jun 3, 2019

Conversation

4 participants
@ebyhr
Copy link
Contributor

commented Jun 1, 2019

Fix #867

Example

$ presto --output-format JSON --execute "select * from tpch.sf1.customer limit 2" | jq
[
  {
    "custkey": 37501,
    "name": "Customer#000037501",
    "address": "Ftb6T5ImHuJ",
    "nationkey": 2,
    "phone": "12-397-688-6719",
    "acctbal": -324.85,
    "mktsegment": "HOUSEHOLD",
    "comment": "pending ideas use carefully. express, ironic platelets use among the furiously regular instructions. "
  },
  {
    "custkey": 37502,
    "name": "Customer#000037502",
    "address": "ppCVXCFV,4JJ97IibbcMB5,aPByjYL07vmOLO 3m",
    "nationkey": 18,
    "phone": "28-515-931-4624",
    "acctbal": 5179.2,
    "mktsegment": "BUILDING",
    "comment": "express deposits. pending, regular deposits wake furiously bold deposits. regular "
  }
]

$ presto --output-format JSON --execute "select * from tpch.sf1.customer limit 2" | jq '.[0].name'
"Customer#000112501"

@cla-bot cla-bot bot added the cla-signed label Jun 1, 2019

@ebyhr ebyhr force-pushed the ebyhr:client/json branch from 9531440 to 0b9178b Jun 1, 2019

@findepi

This comment has been minimized.

Copy link
Member

commented Jun 1, 2019

@ebyhr thanks for your PR!

In #867 i outlined possible output layouts (single JSON object vs a stream of JSON objects; i added examples in the issue).
I imagine stream of JSON objects may be easier to process in... a streaming fashion.
What are your thoughts about this?

@ebyhr

This comment has been minimized.

Copy link
Contributor Author

commented Jun 1, 2019

@findepi Hmm.., it's a difficult choice. How about preparing both format e.g., JSON and JSON_STREAM?

@electrum

This comment has been minimized.

Copy link
Member

commented Jun 1, 2019

I’d keep the shorter option name for the current streaming format.

@ebyhr ebyhr force-pushed the ebyhr:client/json branch from 0b9178b to f767016 Jun 1, 2019

@ebyhr

This comment has been minimized.

Copy link
Contributor Author

commented Jun 1, 2019

Changed to streaming format using JSON option. I imagined some non-jq cases and thought one json is better at first. However, I agree with the current style now.

@electrum

This comment has been minimized.

Copy link
Member

commented Jun 1, 2019

It might be simpler and more efficient to use theJsonGenerator API, since you could loop and write the key/value pairs directly.

@ebyhr ebyhr force-pushed the ebyhr:client/json branch 2 times, most recently from 29a2497 to d32dce0 Jun 2, 2019

@ebyhr

This comment has been minimized.

Copy link
Contributor Author

commented Jun 2, 2019

Updated to JsonGenerator API.

@ebyhr ebyhr force-pushed the ebyhr:client/json branch from d32dce0 to d32f599 Jun 2, 2019

@martint

This comment has been minimized.

Copy link
Member

commented Jun 2, 2019

There's a typo in the commit message: "formt"

@ebyhr ebyhr force-pushed the ebyhr:client/json branch from d32f599 to b441579 Jun 2, 2019

@ebyhr ebyhr changed the title Support JSON CLI output formt Support JSON CLI output form Jun 2, 2019

@ebyhr

This comment has been minimized.

Copy link
Contributor Author

commented Jun 2, 2019

Oh, sorry fixed.

@ebyhr ebyhr force-pushed the ebyhr:client/json branch from b441579 to d444335 Jun 2, 2019

@ebyhr ebyhr changed the title Support JSON CLI output form Support JSON CLI output format Jun 2, 2019

@ebyhr

This comment has been minimized.

Copy link
Contributor Author

commented Jun 3, 2019

The travis failed by PRODUCT_TESTS_BASIC_ENVIRONMENT=true and this commit looks unrelated.

@electrum electrum merged commit daf5ce6 into prestosql:master Jun 3, 2019

1 of 2 checks passed

Travis CI - Pull Request Build Errored
Details
verification/cla-signed
Details
@electrum

This comment has been minimized.

Copy link
Member

commented Jun 3, 2019

Merged, thanks!

@electrum electrum added this to the 314 milestone Jun 3, 2019

@electrum electrum referenced this pull request Jun 7, 2019

Closed

Release notes for 314 #879

2 of 6 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.