Skip to main content
You can define 1 or more test functions in a single block. Each test function accepts a data object as an argument. Within the body of the function, you can write any type of test you want to validate the input data. After the block’s main code is executed, the output data is passed into each test function for validation. If any tests fail, then the block run will also fail.

Example

Here is an example of a transformer block with 2 tests:
You can combine all your data validations into 1 test function or you can split them up into multiple test functions. The benefit of splitting them up is that they can run in parallel, speeding up the data validation.

Log output

Each test run is recorded and can be viewed in the logs. Here is an example:

Data Quality with Great Expectations

Great Expectations

Setup

  1. Before adding expectations to your pipeline, please make sure you have at least 1 data loader, transformer, or data exporter block. They must be Python blocks (SQL block support coming soon). If you don’t have any blocks, add a data loader block and paste the following code:
    For more expectations, read Great Expectation’s documentation.
  2. Add Great Expectations power up to your pipeline.
  3. In the list of available power ups, click the option for Great Expectations. Power ups

Adding expectations to your pipeline

  1. Once you’re on the Great Expectations power up detail page, you can add extension blocks to the current pipeline by clicking the button labeled [+ Extension block].
  2. In dropdown menu, click the template option labeled Empty template.
  3. A popup dialog may appear asking you to enter a name for the new extension block. If it appears, fill in test number of rows as the name and click the button labeled [Save and add block].
  4. Paste the following code in the extension block named test number of rows:
    You can add expectations using code or from a JSON object. See section Defining expectations below for more details.
  5. In the extension block near the bottom, click the input field that says “Select blocks to run expectations on”.
  6. Once you click that input field, a list of blocks from your pipeline will appear.
  7. Check the checkbox on the right side of the dropdown to associate that block to this extension block.
  8. Click the button labeled Save selected blocks.
  9. After you save, a button that is labeled after the name of the block you just selected will appear. For example, if your block is named load_api_data_demo, then a button labeled load_api_data_demo will appear. Great Expectations extension block
  10. Click that button to run your extension block for the block load_api_data_demo.
  11. The output should look something like this:

Other ways to run expectations

Whenever you run a block while editing your pipeline, any associated Great Expectations extension blocks will also be ran. If any expectations fail, the block output will display an error message with the failure results.

Defining expectations

Code

JSON object

Code and JSON object


Running expectations end-to-end

When your pipeline runs, the expectations you defined in your extension blocks will be ran for every associated data loader, transformer, or data exporter block in your pipeline.

Success

If all expectations for a block pass, the success message in the pipeline run logs will look something like this:

Failure

If any expectation fails, the block it was associated with will also fail. You can check the pipeline logs for the block failure. There will be an entry containing the error message with the failure results. It could look something like this: