Skip to main content
elementary.json_schema Allows validating that a string column matches a given JSON schema. The test expects a JSON schema as input, defined according to the JSON schema standard, defined in YAML format (see an example below). This test along with the relevant JSON schema can be auto-generated (see details below).
This test relies on our Python tests capability, and is currently only supported for Snowflake and BigQuery data warehouses.

Auto-generate JSON schema tests

Elementary provides the generate_json_schema_test macro in order to auto-generate the JSON schema for a given column using existing data. Example usage:
Will print:
Note: The generate_json_schema_test macro relies on a 3rd-party python library called genson. If you are using BigQuery, you will need to pre-install this library in your Dataproc cluster (See dbt’s documentation on Python models for more details)