EqualExperts / dbt-unit-testing

This dbt package contains macros to support unit testing that can be (re)used across dbt projects.
MIT License
421 stars 78 forks source link

how to debug a failing test #186

Closed dbrtly closed 8 months ago

dbrtly commented 1 year ago

running the jaffle_shop tests generate this file:

If I change a test in the readme to deliberately make it fail, how do I inspect the failed sql command?

dbt creates static files in target/compiled/tests and target/run/tests but the files this module creates are not useful for debugging.

Also why so much whitespace?

select
      count(*) as failures,
      count(*) != 0 as should_warn,
      count(*) != 0 as should_error
    from (

    select 1 as a from (select 1) as t where False    

    ) dbt_internal_test
dbrtly commented 1 year ago

For clarity, from an optimisation perspective in-memory execution is obviously better but if there was also a manifest (example: tests.json) to inspect the actual sql executed for the tests that would enable reading the exact tests executed.

psousa50 commented 10 months ago

Hi @dbrtly , you can try to add --vars "verbose: true" to your dbt test command:

dbt test ... --vars "verbose: true"

It will display the final SQL that was used to run your test(s).

Please let me know if it helps.

Thank you1