dbt-labs / dbt-project-evaluator

This package contains macros and models to find DAG issues automatically
https://dbt-labs.github.io/dbt-project-evaluator/latest/
Apache License 2.0
440 stars 64 forks source link

Issue with output of print_dbt_project_evaluator_issues #398

Closed nsoria1 closed 4 months ago

nsoria1 commented 10 months ago

Describe the bug

Following these instructions, I used the macro print_dbt_project_evaluator_issues in the property on-run-end. At the end of running dbt_project_evaluator, I get nothing.

on-run-end: "{{ dbt_project_evaluator.print_dbt_project_evaluator_issues() }}"

Steps to reproduce

My dbt_project.yml looks something like this:

config-version: 2

model-paths: ["models"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
seed-paths: ["seeds"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]

vars:
  exclude_paths_from_project: ["/stg_media_status_events.sql", "/stg_user_accounts.sql"]

models:
  dbt_project_evaluator:
    marts:
      structure:
        fct_model_naming_conventions: 
          +enabled: false
        fct_source_directories:
          +enabled: false
        fct_model_directories:
          +enabled: false
      dag:
        fct_staging_dependent_on_staging:
          +enabled: false
        fct_rejoining_of_upstream_concepts:
          +enabled: false

on-run-end: "{{ dbt_project_evaluator.print_dbt_project_evaluator_issues() }}" Run the command:

dbt build package:dbt_project_evaluator

Expected results

I expect dbt_project_evaluator to show up information about the warn steps highlighted in the command.

Screenshots and log output

01:03:48 Finished running 23 table models, 1 seed, 15 view models, 22 tests, 2 hooks in 0 hours 0 minutes and 33.90 seconds (33.90s).
01:03:48 Completed with 2 warnings:
01:03:48 Warning in test valid_test_coverage (models/marts/tests/testing.yml)
01:03:48 Got 1 result, configured to warn if != 0
01:03:48   compiled Code at /app/dbt_project/__local_target/compiled/dbt_project_evaluator/models/marts/tests/testing.yml/valid_test_coverage.sql
01:03:48 Warning in test is_empty_fct_missing_primary_key_tests_ (models/marts/tests/testing.yml)
01:03:48 Got 1 result, configured to warn if != 0
01:03:48   compiled Code at /app/dbt_project/__local_target/compiled/dbt_project_evaluator/models/marts/tests/testing.yml/is_empty_fct_missing_primary_key_tests_.sql
01:03:48 Done. PASS=59 WARN=2 ERROR=0 SKIP=0 TOTAL=61

System information

packages:
  - package: dbt-labs/dbt_utils
    version: 1.1.1
  - package: dbt-labs/dbt_project_evaluator
    version: 0.8.0

Which database are you using dbt with?

The output of dbt --version:

dbt Cloud CLI - 0.34.16 (b16ec451ab12948f2c88d41fa851928511a99d43 2023-11-28T18:04:22Z)

Additional context

Are you interested in contributing the fix?

b-per commented 10 months ago

Thanks for raising this! This is due to the fact that the print() function behaves differently in dbt Core and dbt Cloud. I am checking with the team if there is a way to update the print() behaviour.

I will keep it open for now and will think of a long term solution.

nsoria1 commented 10 months ago

@b-per thanks for the reply! On dbt Cloud should behave correctly? I haven't tested there.

b-per commented 10 months ago

I don't think that dbt Cloud IDE will show the print() results either. I don't know about the dbt Cloud jobs.

sn-nsoria commented 10 months ago

@b-per is there any way to identify the detected resources to simplify the next steps? Otherwise we need to go file by file

b-per commented 10 months ago

Hi @sn-nsoria

What do you mean here?

sn-nsoria commented 10 months ago

Hi @b-per - thanks for replying. I mean, when I got a warn alert for example for some of the rules, how can I identify which models / tables / objects are not following the rule so we can go and fix it? Thanks

b-per commented 10 months ago

Most of the tests (if not all), should start with is_empty_fct_abcd.

To see the failing records, you can:

github-actions[bot] commented 4 months ago

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

github-actions[bot] commented 4 months ago

Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.