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

[Feature] Use --quiet by default for dbt show #9843

Open
3 tasks done
dbeatty10 opened this issue Apr 2, 2024 · 2 comments
Open
3 tasks done

[Feature] Use --quiet by default for dbt show #9843

dbeatty10 opened this issue Apr 2, 2024 · 2 comments
Labels
enhancement New feature or request Refinement Maintainer input needed show related to the dbt show command

Comments

@dbeatty10
Copy link
Contributor

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion

Describe the feature

As described in #9840, It is often useful to pipe or redirect JSON output of dbt show for further downstream processing with a tool like the Python built-in json.tool or the jq swiss army knife.

It would be nice if the syntax were as simple as this to pipe JSON output to a downstream tool:

dbt show -s my_model --output json | python -m json.tool --json-lines

We'd want the --inline flag to be treated the same way as if --select we given instead.

Describe alternatives you've considered

The problem is that we currently need to do some gymnastics with --log-format, --output, and some downstream filtering to extract the desired JSON object 😢

It's certainly possible to require usage of the -q / --quiet flag, but it would be harder for folks to discover that way. If someone passes --output json, they probably want only JSON.

Who will this benefit?

Anyone that want to do any JSON post-processing in a terminal.

Are you interested in contributing this feature?

No response

Anything else?

We'd probably want the same behavior for all three of these subcommands:

  • show (assuming a single node is selected)
  • compile (when a single node is selected)
  • list (regardless the number of nodes selected)

See #7994 for more detail about dbt list specifically.

@dbeatty10 dbeatty10 added enhancement New feature or request triage Refinement Maintainer input needed and removed triage labels Apr 2, 2024
@dbeatty10 dbeatty10 added the show related to the dbt show command label Apr 18, 2024
@joellabes
Copy link
Contributor

This just caught me out too, so wanted to note that it might not have to only be for JSON output.

I ran an inline query and got all the boilerplate:

(dbt-prod) joel@Joel-Labes joel-sandbox % dbt show --inline "select * from ANALYTICS_DEV.dbt_jlabes.salary_data"         
04:01:45  Running with dbt=1.8.2
04:01:45  Registered adapter: snowflake=1.8.2
04:01:46  Found 3 models, 1 snapshot, 1 test, 1 seed, 1 operation, 1 sql operation, 614 macros
04:01:46  
04:01:48  Concurrency: 8 threads (target='dev')
04:01:48  
04:01:49  Previewing inline node:
| EMPLOYEE_ID | NAME     | SALARY | HIRE_DATE  |
| ----------- | -------- | ------ | ---------- |
|           1 | Person 1 |  80000 | 2021-01-01 |
|           2 | Person 2 | 110000 | 2022-01-01 |
|           3 | Person 3 | 120000 | 2023-01-01 |

So thought I'd try using the --quiet flag but it overshot and I got no results at all:

(dbt-prod) joel@Joel-Labes joel-sandbox % dbt --quiet show --inline "select * from ANALYTICS_DEV.dbt_jlabes.salary_data"

Would have preferred

(dbt-prod) joel@Joel-Labes joel-sandbox % dbt --quiet show --inline "select * from ANALYTICS_DEV.dbt_jlabes.salary_data"
| EMPLOYEE_ID | NAME     | SALARY | HIRE_DATE  |
| ----------- | -------- | ------ | ---------- |
|           1 | Person 1 |  80000 | 2021-01-01 |
|           2 | Person 2 | 110000 | 2022-01-01 |
|           3 | Person 3 | 120000 | 2023-01-01 |

but purely for aesthetic reasons, I'm not piping it anywhere (just previewing a couple of tables and wanted a cleaner screenshot)

@MiConnell
Copy link

+1 for compile without logs but with the compiled query. It would be great to run dbt compile -q -s my_model and then pipe it to my clipboard or vscode without the logs at the top.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Refinement Maintainer input needed show related to the dbt show command
Projects
None yet
Development

No branches or pull requests

3 participants