Skip to content

dbt test: Is there a good way to output "what values are invalid" as a failure message? #8407

Answered by gecko655
gecko655 asked this question in Q&A
Discussion options

You must be logged in to vote

I noticed that I could use the dbt show command (added in dbt 1.5) to show test results saved by store_failure.
This seems to meet my requirements.

doc: https://docs.getdbt.com/reference/commands/show

So, my CI script is going to look like this:

# prerequisite: jq

# Delete previous log if exists
rm -f logs/dbt.log

# Execute the test and show human readable output while output json log file
dbt --log-format-file json test --store-failures -t dev

# Extract the failed test node names
# note: Z022 is 'RunResultFailure' log ( https://github.com/dbt-labs/dbt-core/blob/5814928e3836467ffa90297e871d8a99f8c8b855/core/dbt/events/types.py#L2121-L2128 )
failed_test_names="$(cat logs/dbt.log | jq -r '

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@gecko655
Comment options

@jtcohen6
Comment options

@gecko655
Comment options

Comment options

You must be logged in to vote
2 replies
@jtcohen6
Comment options

@gecko655
Comment options

Answer selected by gecko655
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants