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

unable to exclude specific model from pre-commit #189

Open
adiayao opened this issue Feb 15, 2024 · 0 comments
Open

unable to exclude specific model from pre-commit #189

adiayao opened this issue Feb 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@adiayao
Copy link

adiayao commented Feb 15, 2024

Background:

In my dbt project, I encountered a limitation with the check-source-has-tests-by-group hook in the pre-commit configuration, specifically when trying to exclude specific models that do not have grain. These models are defined within a single YAML file.
According to the dbt-checkpoint exclusion documentation, exclusion seems to apply only to entire files rather than specific models or tables within those files.

I have attempted couple ways to specify the exclusions in more granular way, including using file paths and adjusting the exclude parameter's placement. But I have not successfully excluded specific models from the grain test requirement.

For example, I tried using the file path by leveling down to table name. This is something shown in issue #119

- id: check-source-has-tests-by-group
  description: "Ensures that the model has a number of tests"
  args: ["--tests", "unique", "expect_compound_columns_to_be_unique", "--test-cnt","1", "--exclude","models/tablename", "--"]

Workaround:

I've temporarily resolved this by segregating the non-grain models into separate YAML files and applying a regex pattern in the pre-commit configuration to exclude those files:
exclude: ^models/staging/.*/.*nongrain\.yml$

Request:

Is this a limitation/bug or an area for a new feature? Currently, I'm managing exclusions for grain tests, but similar needs may arise for other tests. The requirement to create separate YAML files for different exclusions leads to a fragmented project structure.

I'm hoping for a solution that allows for exclusions at a more granular level, ideally through fully qualified names (fqn) or a similar method that supports specific models or tables within a YAML file. This enhancement would streamline configurations and maintain a cohesive project structure.

@adiayao adiayao added the enhancement New feature or request label Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant