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

check-model-parents-and-childs does not consider seeds as parents #153

Open
mmartinenvato opened this issue Sep 29, 2023 · 1 comment
Open
Labels
bug Something isn't working priority: low

Comments

@mmartinenvato
Copy link

Describe the bug

The check-model-parents-and-childs hook does not consider seeds as parents, so if a model only has a seed as a parent, it throws a failure when configured to have --min-parent-count > 0

To Reproduce
Steps to reproduce the behavior:

  1. Add hook to pre-commit config:
  - repo: https://github.com/dbt-checkpoint/dbt-checkpoint
    rev: v1.1.1
    hooks:
      - id: check-model-parents-and-childs
        args: ["--min-parent-cnt", "1", "--"]
  1. Create seed under seeds directory

seeds/<schema>/cfg_countries.csv

country_code_iso_alpha2,country_code_iso_alpha3,country_code_iso_numeric,country_name,world_region,continent,currency_code,currency_name
AD,AND,020,"Andorra",Europe,Europe,EUR,Euro
AE,ARE,784,"United Arab Emirates",Asia,Asia,AED,Dirham
...

seeds/_seeds.yml

version: 2

seeds:
  - name: cfg_countries
     schema: <schema>
  ...
  1. Create model under models directory which references the seed as a parent

models/<schema>/dim_countries.sql

with
country as (
    select * from {{ ref('cfg_countries') }}
)
select * from country

models/_models.yml

version: 2

models:
  - name: dim_countries
  1. Run dbt seed and dbt build so model is in manifest (as required by the hook)

  2. run pre-commit and see error:

pre-commit run check-model-parents-and-childs
Check the model has a parents/childs.....................................Failed
- hook id: check-model-parents-and-childs
- exit code: 1

dim_countries: has 0 min, but min 1is/are required.

Expected behavior

The hook recognises a seed as a parent for the purposes of a min-parent-count

Version:
v1.1.1

Additional context
Add any other context about the problem here.

@mmartinenvato mmartinenvato added the bug Something isn't working label Sep 29, 2023
@aungyee
Copy link

aungyee commented Mar 7, 2024

I have a similar issue with snapshots. check-model-parents-and-childs does not consider snapshots as parents.

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

No branches or pull requests

3 participants