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 panel now has a tab named "Tests" in addition to "Documentation". Enable it by clicking on it. You can enable documentation, tests, or both by using the tabs at the 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 the 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 a test definition is not available from packages (dbt.utils or dbt.expectations) that you have installed in your environment, DataPilot writes custom SQL test code and puts it in the dbt macro.

This functionality is marked as beta. 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 the "pencil" icon from the details screen. You can delete any dbt test by clicking on the test and using the "trash can icon" from the details screen

Edit tests

Getting distinct values for "accepted_values" test

As shown in the image above, there is a button to quickly get distinct values for a specific column with a click of a button. This helps you write the "accepted_values" test easily.

Save changes in YAML file

You can save the changes in the existing or a new YAML file with save button at the bottom of the panel. If you see any issues with the content that's saved in the YAML file, please check the optional config section.

Recorded demo video