Schema changes from baseline

The elementary.schema_changes_from_baseline test checks for schema changes against baseline columns defined in a source's or model's configuration. For this test to work, the configuration should contain columns and data types.

Sources configuration

version: 2

sources:
  - name: < source name >
    database: < database name >
    schema: < schema name >
    tables:
      - name: < table name >
        columns:
          - name: < column 1 >
            data_type: < data type 1 >
          - name: < column 2 >
            data_type: < data type 2 >
        tests:
          - elementary.schema_changes_from_baseline

Models configuration

Supported Parameters

  • fail_on_added: If set, the test will fail if there are columns in the table that do not exist in the baseline (default: False).

  • enforce_types: If set, the test will raise an error if there are columns defined without a data type (default: False).

Auto-generate Baseline Schema

To make it easier to configure schema tests, Elementary provides dbt operations to auto-generate tests configuration based on the existing schemas.

Usage

This command will output the generated configuration for the schema changes from baseline test, which can be copied and pasted into the relevant yml file.

Last updated

Was this helpful?