Skip to main content

Custom Tests

Collate’s built-in tests cover most use cases, but sometimes you need something more specific. You can bring in results from your own test suite or define entirely new tests that run inside Collate — all through the API and the Python SDK. The setup involves five steps:
  1. Create a Test Definition
  2. Create a Test Suite
  3. Create a Test Case
  4. Write Test Case Results
  5. (Optional) Make the test available in the Collate UI

Step 1: Create a Test Definition

A Test Definition tells Collate what your test is: its name, what entity type it applies to (table or column), and which platforms run it. Send a POST request to /api/v1/dataQuality/testDefinition with at least the following fields:
Here is a complete cURL example:
Save the universally unique identifier (UUID) from the response — you’ll need it to create the Test Case. Heads up: To make this test definition available in the Collate UI, include Collate in testPlatforms. That requires extra setup covered in Step 5. If you only want to build a UI-executable test, go to Step 5.

Step 2: Create a Test Suite

A Test Suite groups Test Cases together for scheduling and ownership. You can create a new one or reuse an existing suite. Send a POST request to /api/v1/dataQuality/testSuites/executable:
Here is a complete cURL example:
Save the UUID from the response — you’ll need it in the next step.

Step 3: Create a Test Case

A Test Case is a specific instance of your Test Definition applied to a table or column. It uses the fully qualified name (FQN) to reference the test definition and suite. Send a POST request to /api/v1/dataQuality/testCases:
Important: Include the opening and closing <> in the entityLink value. Here is a complete cURL example:
Save the UUID from the response

Step 4: Write Test Case Results

Note: This step is optional if you’re running the test through the Collate UI.
After your Test Case exists, push results to it with a PUT request to /api/v1/dataQuality/testCases/{test FQN}/testCaseResult:
Here is a complete cURL example:
Your test now appears in the Test Suite and on the table entity page.

Step 5: (Optional) Make Your Test Available in the Collate UI

To make your custom test available in the Collate UI — so anyone can run it without touching the API — wire it up using the Collate data_quality namespace submodule.
  1. Create your namespace package Start by creating a Python package that holds your test logic. At minimum, your package needs this structure:
    Place your test file in the right location based on the entity type:
    • Table tests: metadata/data_quality/validations/table/sqlalchemy/<yourTest>.py
    • Column tests: metadata/data_quality/validations/column/sqlalchemy/<yourTest>.py
    The filename (<yourTest>) must match the test name you used in Step 1. Important: Add an __init__.py file to every folder with this line:
  2. Create your test class In your <yourTest>.py file, create a class named <YourTest>Validator that inherits from BaseTestValidator. Optionally inherit from SQAValidatorMixin too — it gives you extra helper methods out of the box. Implement the run_validation method, which must return a TestCaseResult object. See a full working example in the OpenMetadata validator source tree — it implements an entropy test end to end.
  3. Install your package Once your package is ready, install it in the same environment where the Collate Python SDK is installed:
    Custom test definition created in Collate UI Custom test case result displayed in Collate UI