Skip to content

Add JSON output format to CLI#22181

Merged
tdcmeehan merged 1 commit intoprestodb:masterfrom
ZacBlanco:upstream-cli-json-output
Mar 13, 2024
Merged

Add JSON output format to CLI#22181
tdcmeehan merged 1 commit intoprestodb:masterfrom
ZacBlanco:upstream-cli-json-output

Conversation

@ZacBlanco
Copy link
Contributor

@ZacBlanco ZacBlanco commented Mar 13, 2024

Description

Cherry-pick of trinodb/trino#878

Adds --output-format JSON as a valid option for the CLI.

Motivation and Context

Useful for piping query output to jq, or when trying to retrieve a JSON query plan.

Impact

N/A

Test Plan

Tests are included in the patch

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

== RELEASE NOTES ==

General Changes
* JSON is now a supported output format in the Presto CLI

@ZacBlanco ZacBlanco requested a review from a team as a code owner March 13, 2024 05:12
@ZacBlanco ZacBlanco force-pushed the upstream-cli-json-output branch from 97855f5 to cc141ce Compare March 13, 2024 05:22
@ZacBlanco
Copy link
Contributor Author

@ClarenceThreepwood this will allow us to get a query plan like so:

./presto-cli/target/presto-cli-0.287-SNAPSHOT-executable.jar  \
    --catalog iceberg \
    --schema tpch \
    --execute 'EXPLAIN (format JSON) SELECT 1 from lineitem' \
    --output-format JSON | jq '.["Query Plan"] | fromjson' > plan.json

@ZacBlanco ZacBlanco requested a review from aaneja March 13, 2024 06:19
@imjalpreet imjalpreet linked an issue Mar 13, 2024 that may be closed by this pull request
@tdcmeehan
Copy link
Contributor

Please attribute the commit message (see https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#commit-message-style backport commits)

Cherry-pick of trinodb/trino@daf5ce6
Co-authored-by: Yuya Ebihara <ebyhry@gmail.com>
@ZacBlanco ZacBlanco force-pushed the upstream-cli-json-output branch from cc141ce to fdee707 Compare March 13, 2024 18:59
@ZacBlanco
Copy link
Contributor Author

Please attribute the commit message (see https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#commit-message-style backport commits)

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add JSON CLI output format

3 participants