Skip to content

Generate and edit tests

You can generate, view, edit and delete dbt tests in UI with this functionality.

Following are a few limitations

Enable Tests Tab

The documentation editor bottom panel now has additional tab on top named "Tests" in adidtion to "Documentation". Enable it by clicking on it.You can enable either documentation or tests or both by using tabs on top.

Enable tests tab

For columns that are not referenced in the dbt model, you can click “sync with db” button to get those columns shown in the documentation editor.

View dbt Tests

The documentation editor shows the tests that have been added for dbt model and columns. You can see the details of the tests by clicking on the test name.

View tests

Add dbt Tests

You can add default dbt tests: unique, not_null, accepted_values, relationship by clicking (+) sign next to the "Tests:" label.

Add tests

Generate dbt Tests (Beta)

You can also generate test code for custom tests based on dbt.utils and dbt.expectations package. First, click on (+) sign next to the "Tests:" label and choose "custom tests". DataPilot automatically detects which dbt packages you have installed, and it generates test code based on packages in your environment.

If test definition is not available from packages (dbt.utils or dbt.expectations) that you have installed in your environment, DataPilot write custom SQL test code and put it in dbt macro.

This functionality is marked as beta as in some rare cases datapilot may decide to ignore the packages that you have installed or may generate inaccurate code.

Generate tests

Edit / delete dbt Tests

You can edit existing dbt tests if they are default dbt tests: unique, not_null, accepted_values, relationships by clicking on the test and using "pencil" icon from details screen. You can delete any dbt test by clicking on the test and using "trash can icon" from details screen

Edit tests

Getting distinct values for "accepted_values" test

In order to facilitate writing "accepted_values" test easily, there is a button to quickly get distinct values for a specific column with a click of button as shown in the image above.

In the end you can save the changes in the existing or a new YAML file with the widget at the bottom of the panel

Recorded demo video