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

[Bug] catalog.json includes all nodes even when no nodes are selected during dbt docs generate #8794

Closed
2 tasks done
Tracked by #8316
dbeatty10 opened this issue Oct 7, 2023 · 2 comments
Closed
2 tasks done
Tracked by #8316
Assignees
Labels
backport 1.7.latest bug Something isn't working

Comments

@dbeatty10
Copy link
Contributor

dbeatty10 commented Oct 7, 2023

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

When no nodes are selected during dbt docs generate, then target/catalog.json includes all nodes (rather than 0 nodes).

Expected Behavior

Expected that target/catalog.json would contain 0 nodes rather than all nodes.

i.e., expected that it would be the same as when running dbt docs generate --empty-catalog:

{
  "metadata": {
    "dbt_schema_version": "https://schemas.getdbt.com/dbt/catalog/v1.json",
    "dbt_version": "1.7.0b2",
    "generated_at": "2023-10-07T13:34:04.627535Z",
    "invocation_id": "c09b4da4-35c5-418d-8a4b-447d2925f075",
    "env": {}
  },
  "nodes": {},
  "sources": {},
  "errors": null
}

Steps To Reproduce

  1. Start with a project with more than one dbt model
  2. Run dbt docs generate --select nothing (where there is no node named nothing)
  3. Examine target/catalog.json
  4. Notice that it includes all nodes rather than 0 nodes

Relevant log output

dbt docs generate --select nothing
[0m08:42:03.885769 [warn ] [MainThread]: The selection criterion 'nothing' does not match any nodes
[0m08:42:03.886607 [info ] [MainThread]: 
[0m08:42:03.887076 [warn ] [MainThread]: Nothing to do. Try checking your model configs and model specification args
[0m08:42:03.887696 [debug] [MainThread]: Command end result
[0m08:42:03.910804 [debug] [MainThread]: Acquiring new postgres connection 'generate_catalog'
[0m08:42:03.911372 [info ] [MainThread]: Building catalog
[0m08:42:03.913022 [debug] [ThreadPool]: Acquiring new postgres connection 'postgres.information_schema'
[0m08:42:03.924920 [debug] [ThreadPool]: Using postgres connection "postgres.information_schema"
[0m08:42:03.925472 [debug] [ThreadPool]: On postgres.information_schema: BEGIN
[0m08:42:03.925910 [debug] [ThreadPool]: Opening a new connection, currently in state init
[0m08:42:04.114544 [debug] [ThreadPool]: SQL status: BEGIN in 0.0 seconds
[0m08:42:04.115114 [debug] [ThreadPool]: Using postgres connection "postgres.information_schema"
[0m08:42:04.115666 [debug] [ThreadPool]: On postgres.information_schema: /* {"app": "dbt", "dbt_version": "1.7.0b2", "profile_name": "sandcastle", "target_name": "postgres", "connection_name": "postgres.information_schema"} */

Environment

- OS: N/A
- Python: N/A
- dbt: `main` branch for 1.7.0-b2

Which database adapter are you using with dbt?

postgres

Additional Context

In case it is helpful in some way, my hack here contains logic for selecting 0 nodes rather than all nodes.

@dbeatty10 dbeatty10 added bug Something isn't working triage labels Oct 7, 2023
@github-actions github-actions bot changed the title [Bug] <title> [CT-3192] [Bug] <title> Oct 7, 2023
@dbeatty10 dbeatty10 changed the title [CT-3192] [Bug] <title> [Bug] catalog.json includes all nodes even when no nodes are selected during dbt docs generate Oct 7, 2023
@dbeatty10 dbeatty10 removed the triage label Oct 7, 2023
@graciegoheen
Copy link
Contributor

graciegoheen commented Oct 9, 2023

Notes from refinement:

  • We need to add an additional if test for when there are no selected nodes
  • make a test case

@peterallenwebb
Copy link
Contributor

This behavior was fixed as a secondary benefit of my work on #8846. A test demonstrating the fix can be seen here. The test shows that a selector that doesn't match any nodes generates a catalog with no entries, rather than a catalog with every entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.7.latest bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants