dbt-checkpoint / dbt-checkpoint

:fishing_pole_and_fish: List of `pre-commit` hooks to ensure the quality of your `dbt` projects.
MIT License
595 stars 119 forks source link

Issue with the check-column-name-contract hook #42

Open john-jerome opened 2 years ago

john-jerome commented 2 years ago

Hello folks,

first I noticed that on this page when clicking on check-column-name-contract you get a 404 page. However, today I've decided to actually use this hook in my project and got the following error:

[ERROR] `check-column-name-contract` is not present in repository https://github.com/offbi/pre-commit-dbt. Typo? Perhaps it is introduced in a newer version? Often `pre-commit autoupdate` fixes this.

To Reproduce Steps to reproduce the behavior:

  1. add check-column-name-contract to your config file
  2. run pre-commit

Version: v1.0.0

john-jerome commented 2 years ago

Hey, I believe this issue is still relevant - the web page is broken and the corresponding hook still doesn't work.

robertdefilippi commented 2 years ago

I'm also encountering the same error with 1.0.0

robertdefilippi commented 2 years ago

Can confirm using this commit outlined here, fixes the issue of not being able to find the command 🙂

https://github.com/offbi/pre-commit-dbt/issues/56

.pre-commit.yaml

...
  - repo: https://github.com/offbi/pre-commit-dbt
    rev: ea9c6bafbca375250baa9c21b8ddf9207d9c0160
    hooks:
        - id: check-model-has-description
        - id: check-model-name-contract
          args: [--pattern, "(base_|stg_).*"]
          files: models/staging/
...

However, I'm not sure the command is running correctly as I keep getting an error.

The model is under this path models/staging/seeds/stg_countries.sql and check-model-name-contract keeps failing even though it starts with stg_ I'm also getting an error code which is not entirely helpful at debugging what the issue ie.

dbt docs generate........................................................Failed
- hook id: dbt-docs-generate
- exit code: 1

Executing cmd: `dbt docs generate`

Check staging models start with base_ or stg_............................Failed
- hook id: check-model-name-contract
- exit code: 1
john-jerome commented 2 years ago

I can confirm that the commit mentioned by @robertdefilippi fixes the issue with check-column-name-contract as well

daniel-inventa commented 2 years ago

Also experiencing this. Accidentally filed a ticket in the wrong repo earlier 😅

https://github.com/sqlfluff/sqlfluff/issues/3244

followingell commented 1 year ago

❗ ❗ ❗

Just reiterating that people should take note of @robertdefilippi's "not sure the command is running correctly" comment below and assume that, even when using rev: ea9c6bafbca375250baa9c21b8ddf9207d9c0160 that this hook is broken.

During testing I saw no issues and had this running as expected like others have noted, however, very infrequently I encountered the issue below whereby dbt docs generate is shown as failed however, this is seemingly caused by check-model-name-contract:

However, I'm not sure the command is running correctly as I keep getting an error.

The model is under this path models/staging/seeds/stgcountries.sql and check-model-name-contract keeps failing even though it starts with stg I'm also getting an error code which is not entirely helpful at debugging what the issue ie.

dbt docs generate........................................................Failed
- hook id: dbt-docs-generate
- exit code: 1

Executing cmd: `dbt docs generate`

Check staging models start with base_ or stg_............................Failed
- hook id: check-model-name-contract
- exit code: 1