hey <@U088WCP3B4P> how can I get a data quality su...
# ask-elementary-ai
r
hey @kapa.ai how can I get a data quality summary after executing dbt test in a model, getting percentage of errors from total records
k
A message from kapa.ai
New message text here
r
Thanks @kapa.ai, I'm using open-source version, so I will need manual calculation. What is the best way to configure dbt project, to capture failing records?
k
A message from kapa.ai
To capture failing records in Elementary Data's open-source version, you'll need to configure your dbt project properly. Here's how to set it up: ### 1. Configure test_sample_row_count By default, Elementary only stores 5 sample rows of failed test results. To capture more or all failing records, modify your `dbt_project.yml`:
Copy code
yaml vars:   elementary:     test_sample_row_count: -1  # Set to -1 to store all failing rows
This configuration tells Elementary to store all failing rows instead of just a sample [GitHub Issue #1652](https://github.com/elementary-data/elementary/issues/1652). ### 2. Enable store_failures for tests For individual tests, you can enable the
store_failures
config:
Copy code
yaml tests:   - not_null:       config:         store_failures: true
### 3. Add required flags (for some environments) Some users have reported needing these flags in their
dbt_project.yml
to properly store test results:
Copy code
yaml flags:   require_explicit_package_overrides_for_builtin_materializations: false   source_freshness_run_project_hooks: True
### 4. Run Elementary models Make sure Elementary's models are up to date:
Copy code
dbt deps dbt run -s elementary
Then run your tests:
Copy code
dbt test
### Accessing the failed records After running tests, you can find the failed records in: -
elementary_test_results
- Contains test metadata and results -
test_result_rows
- Contains samples of the actual failing rows Note that even with
test_sample_row_count: -1
, some test types (like aggregation tests) won't store all individual failing rows due to how they're structured. For calculating percentages, you'll need to: 1. Query the failed records from Elementary tables 2. Query the total count from your actual models 3. Calculate the percentage manually Several community members have created custom dbt models that extract this information using regex on test messages and joining with table row counts to calculate quality percentages. Would you like more specific guidance on querying these tables or creating a custom model for your percentage calculations? I'm here to help you implement this solution for your open-source Elementary setup. P.S. If you're using specific test types like uniqueness tests, you might also want to explore the
fail_calc
parameter as mentioned in our previous conversation. P.P.S. If you're using Athena, make sure to check that your test_result_rows table is populated correctly, as some users have reported issues with this specific database. P.P.P.S. If you're using Microsoft Teams for alerts, be aware of a current bug where not all alerts that should be sent are received, which could affect your monitoring of test failures [GitHub Issue #1652](https://github.com/elementary-data/elementary/issues/1652).
n
Hey @Ricardo Bravo! Was this helpful? 🙂