Use a Custom Expectation
Use the information provided here to use Custom Expectations you created or imported from the Great Expectations Experimental Library.
Custom ExpectationsA verifiable assertion about data. extend the core functionality of Great Expectations for a specific purpose or business need. Often, they are less stable and less mature than the core library. For these reasons they are not available from the core library, and they must be registered and imported when you create an Expectation SuiteA collection of verifiable assertions about data., and when you define and run a CheckpointThe primary means for validating data in a production deployment of Great Expectations..
When you instantiate your Data ContextThe primary entry point for a Great Expectations deployment, with configurations and methods for all supporting components., all plugins in the great_expectations/plugins
directory are automatically available,
and this allows you to import your Custom Expectation from other locations.
If you're using a Custom Expectation without a Filesystem Data Context, you'll need to package and install the Custom Expectation as a Python package, or you'll need to make the complete code for the Custom Expectation available locally where it is executed. For example, if you're creating a Validator, setting Expectations or Custom Expectations, and executing a Checkpoint in a Databricks notebook, the Metric and Expectation class for your Custom Expectation must be defined within the same notebook before calling get_context()
.
Prerequisites
- Completion of the Quickstart.
- A configured and functional development environment.
- A Custom ExpectationAn extension of the `Expectation` class, developed outside of the Great Expectations library. or a Custom Expectation from the Great Expectations Experimental Library
Import a custom Expectation you created
Add your Custom Expectation to the
great_expectations/plugins/expectations
folder of your Great Expectations deployment.Run a command similar to the following:
```python
from expectations.expect_column_values_to_be_alphabetical import ExpectColumnValuesToBeAlphabetical
# ...
validator.expect_column_values_to_be_alphabetical(column="test")
```
Import a contributed custom Expectation
If you're using a Custom Expectation from the Great Expectations Experimental
library, you'll need to import it.
Run
pip install great_expectations_experimental
.Run a command similar to the following:
```python
from great_expectations_experimental.expectations.expect_column_values_to_be_alphabetical import ExpectColumnValuesToBeAlphabetical
# ...
validator.expect_column_values_to_be_alphabetical(column="test")
```