Failed Rows Sample
When a test fails, you often need to see the rows that caused the failure. The failed rows sample is a small table of those rows. It appears on the test case page, so you can inspect bad data without leaving OpenMetadata. The failed rows sample is part of OpenMetadata. It is not limited to Collate.Where You See It
OpenMetadata fills the sample on its own for tests that it runs itself, such as tests you create in the UI or in a data quality workflow. Open the test case page and stay on the Test Case Results tab. Scroll to the Sample Data section. It shows the failed rows, and it highlights the column that failed the test.
dbt and Externally Run Tests
OpenMetadata doesn’t fill the sample for tests it only imports, such as dbt tests. The imported result tells OpenMetadata that a test failed, but not which rows. You can add those rows yourself through the API. Use this for any result that comes from outside OpenMetadata.Before You Start
- The test case must already exist in OpenMetadata. For dbt, run the dbt workflow so the tests are imported. dbt tests appear in OpenMetadata under the name of the dbt test.
- The test case’s latest result must have failed rows. This means the result is
Failed, or it’sSuccesswith at least one failed row. If it isn’t, the API returnsFailed rows can only be added to a test case whose latest result has failed rows. - Your user or bot needs the permission to edit tests. To read the sample, it needs the permission to view failed rows samples.
Add the Sample
Send aPUT request to the test case:
The API has no limit on the number of rows. Send a small sample, because OpenMetadata stores what you send and shows it in the UI.
To get the test case id, look the test case up by its fully qualified name:
id is in the response.
To read or remove a sample, use GET or DELETE on the same /api/v1/dataQuality/testCases/{id}/failedRowsSample path.
Example: dbt Failed Rows
dbt can store the rows that fail a test in a table in your warehouse. Turn it on withstore_failures in your dbt project. dbt then records that table’s name in run_results.json, in the relation_name field of each test result.
A common setup adds one step after the dbt run and its import into OpenMetadata. For example, an Airflow task that:
- Reads
run_results.jsonand picks the tests with the statusfail. - Reads a sample of rows from each failed test’s
relation_nametable. - Finds the matching OpenMetadata test case and calls the API above.
TEST_CASE_FQNS map with your own values, and swap read_failed_rows for a query against your warehouse.
Run this step only after the dbt workflow has imported the latest results. If the test case’s latest result in OpenMetadata is still an older passing result, the API rejects the sample.