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

[CT-3301] [Bug] sources are not disabled in dbt_project.yml #8960

Closed
2 tasks done
epapineau opened this issue Nov 1, 2023 · 4 comments
Closed
2 tasks done

[CT-3301] [Bug] sources are not disabled in dbt_project.yml #8960

epapineau opened this issue Nov 1, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@epapineau
Copy link
Contributor

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

Disabling an entire source in dbt_project.yml does not work for in-project sources although it does work in the sources.yml or for package sources. For example, the following in dbt_project.yml will not disable the source:

sources:
  project_name:
    source_name:
      +enabled: false

But in sources.yml this will disable the source:

sources:
  - name: source_name
    config:
      enabled: false

Expected Behavior

The ability to toggle the enabled configuration across all configuration levels.

Steps To Reproduce

  1. Define a source and add the enabled config to `dbt_project.yml

Relevant log output

No response

Environment

- OS:
- Python:
- dbt:

Which database adapter are you using with dbt?

snowflake

Additional Context

No response

@epapineau epapineau added bug Something isn't working triage labels Nov 1, 2023
@github-actions github-actions bot changed the title [Bug] sources are not disabled in dbt_project.yml [CT-3301] [Bug] sources are not disabled in dbt_project.yml Nov 1, 2023
@graciegoheen
Copy link
Contributor

Hey Elize - after doing some troubleshooting, it looks like our docs might actually be wrong / misleading.

If your source is nested in a yml file in a subfolder, you will need to supply the path to that yml file plus the source name in the dbt_project.yml file.

sources:
  project_name:
    staging:
      my_source_folder:
        source_name:
          +enabled: false

Can you give something like that a try (depending on the path to your source yml file)?

In part this is confusing, because the output of dbt list is not the fqn of the source (it's the selector). We have an open issue for this - #8599.

I think these are the docs we need to update:

Looks like we had a similar issue / confusion come up for disabling tests #8876

@mirnawong1
Copy link
Contributor

hey @graciegoheen ! ok thank you for clarifying this and had a few reads to understand the change.

I've created a PR here which addresses the above and also adds the resource paths doc to the sidebar. for some reason, it wasn't on there and i think it should be on the sidebar?

can i ask you to take a look to ensure it's technically right?

@epapineau
Copy link
Contributor Author

@graciegoheen Yes when I provide the project name and path I get the expected behavior. Thank you for your help here everyone~

mirnawong1 added a commit to dbt-labs/docs.getdbt.com that referenced this issue Nov 7, 2023
PR clarifies how to disable sources and addresses core issue
dbt-labs/dbt-core#8960 and adds the resource
paths page to the sidebar.

This also Resolves #4313
@dbeatty10 dbeatty10 removed the triage label Nov 7, 2023
@dbeatty10
Copy link
Contributor

How to disable a single table within a source

Suppose you have a super tiny dbt project that looks like this:

.
├── dbt_project.yml
└── models
    └── subdirectory_name
        └── _sources.yml

And you have two source tables defined within models/subdirectory_name/_sources.yml:

# models/subdirectory_name/_sources.yml

version: 2

sources:
  - name: my_source_name
    tables:
      - name: my_source_table_1
      - name: my_source_table_2

You can list them like this:

$ dbt list
...
00:00:28  Found 2 sources, 0 exposures, 0 metrics, 401 macros, 0 groups, 0 semantic models
source:your_project_name.my_source_name.my_source_table_1
source:your_project_name.my_source_name.my_source_table_2

Then to disable just the first table, you'd do the following within dbt_project.yml:

# dbt_project.yml

name: "your_project_name"
version: "1.0.0"
config-version: 2
profile: "sandcastle"

sources:
  your_project_name:
    subdirectory_name:
      my_source_name:
        my_source_table_1:
          +enabled: false

And when you do another listing, you'll see it's been disabled:

$ dbt list
...
00:01:10  Found 1 source, 0 exposures, 0 metrics, 401 macros, 0 groups, 0 semantic models
source:your_project_name.my_source_name.my_source_table_2

Potential mistake

But if you don't get the hierarchy within dbt_project.yml juuuuust right, then the enabled config won't have the effect you desire, and it will give an warning like this:

00:10:35  [WARNING]: Configuration paths exist in your dbt_project.yml file which do not apply to any resources.
There are 1 unused configuration paths:
- sources.your_project_name.subdirectory_name.my_source_name__misnamed.my_source_table_1

mirnawong1 added a commit to dbt-labs/docs.getdbt.com that referenced this issue Nov 8, 2023
Previews:
-
[resource-path](https://docs-getdbt-com-git-dbeatty-sources-enabled-config-dbt-labs.vercel.app/reference/resource-configs/resource-path#apply-config-to-a-source-nested-in-a-subfolder)
-
[source-configs](https://docs-getdbt-com-git-dbeatty-sources-enabled-config-dbt-labs.vercel.app/reference/source-configs#configuring-sources)

## What are you changing in this pull request and why?

Just tested this out and wrote an example
[here](dbt-labs/dbt-core#8960 (comment)).
Using the learnings to update the docs.

Updated to use the lowest level of granularity (which is a source
table).

## Checklist
- [x] Review the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md)
and [About
versioning](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#adding-a-new-version)
so my content adheres to these guidelines.
- [x] I have verified that the preview looks good
- [x] I have verified that the code example works
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants