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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dbt show and dbt compile to output JSON without extra logs #9958

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dbeatty10
Copy link
Contributor

@dbeatty10 dbeatty10 commented Apr 16, 2024

resolves #9840

Problem

As described in #9840:

I would like the output of dbt show to be valid JSON, containing just the data and no logs.

dbt list uses the --quiet flag to isolate the desired output from the log output, allowing the results to be piped or redirected.

But currently, dbt show and dbt compile to not work similarly.

Solution

Adopt the same exact approach as dbt list here, and basically copy-paste the code it uses.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • 馃憟 This PR includes tests, or tests are not required/relevant for this PR
  • This PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

@cla-bot cla-bot bot added the cla:yes label Apr 16, 2024
fire_event(compiled_node_event)
else:
# Cleaner to leave as print than to mutate the logger not to print timestamps.
print(compiled_node_event.message())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use the new PrintEvent being added to dbt-common.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I'll check out dbt-labs/dbt-common#130 and give PrintEvent a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: see #10131 for an example how to use PrintEvent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Allow dbt show to output json data without extra logs (by updating --quiet)
2 participants