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-has-properties-file fails on macros with property files #169

Open
david-whimsical opened this issue Dec 18, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@david-whimsical
Copy link

david-whimsical commented Dec 18, 2023

Describe the bug

  1. check-model-has-properties-file is run on macros, even though macros aren't models.
  2. check-model-has-properties-file fails for macros, even though we did create a corresponding property file.

To Reproduce
Steps to reproduce the behavior:

  1. Install dbt-redshift==1.6.2
  2. Create a test.sql
  3. Create a corresponding property file for that macro

Expected behavior

  1. The hook should be skipped, as we're creating a macro not a model.
  2. If it's supposed to run on all nodes, then this hook should succeed, as the property file exists and is staged.

Version:

Version 1.1.0, using dbt-redshift==1.6.2

Additional context

[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /Users/davidbaussart/.cache/pre-commit/patch1702910336-22189.
Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed
Check Yaml...............................................................Passed
Check for added large files..............................................Passed
Check the script does not contain a semicolon............................Passed
Check the script has not table name......................................Passed
Check the script has existing refs and sources...........................Passed
Check the model has properties file......................................Failed
- hook id: check-model-has-properties-file
- exit code: 1

transform/macros/test.sql: does not have model properties defined in any .yml file.

Both files are staged in git – they're the only files staged.

Contents of transform/macros/test.yml

version: 2

macros:
  - name: test
    description: test

Contents of transform/macros/test.sql

{% macro test() %}
'test'
{% endmacro %}

Content of our pre-commit config file

# .pre-commit-config.yaml
fail_fast: true

files: ^transform
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-added-large-files

  - repo: https://github.com/dbt-checkpoint/dbt-checkpoint
    rev: v1.1.0
    hooks:
      # script checks, stuff that could make us loose  time
      - id: check-script-semicolon
        args: ["--manifest", "transform/target/manifest.json", "--"]

      - id: check-script-has-no-table-name
        args: ["--manifest", "transform/target/manifest.json", "--"]

      - id: check-script-ref-and-source
        args: ["--manifest", "transform/target/manifest.json", "--"]

      # checking dbt property files
      - id: check-model-has-properties-file # property file exists
        args: ["--manifest", "transform/target/manifest.json", "--"]

      - id: check-model-has-description # a model desc is added
        args: ["--manifest", "transform/target/manifest.json", "--"]

      - id: check-model-has-meta-keys # an owner is added
        args:
          [
            "--manifest",
            "transform/target/manifest.json",
            "--meta-keys",
            "owner",
            "--",
          ]
@david-whimsical david-whimsical added the bug Something isn't working label Dec 18, 2023
@nathan-g-2degrees
Copy link

nathan-g-2degrees commented May 22, 2024

Reproduced with:
Python 3.10.10
dbt 1.7.14
Snowflake
dbt-checkpoint v2.0.1

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

2 participants