Product Subscriptions

Product Subscriptions

Data Contract Template

Data Contract Template

Ensure Subscriptions data is fresh, complete, and reliable before its used for billing, revenue reporting, and entitlement decisions.

Data contract description

This data contract enforces schema stability, a 24-hour freshness SLA, and required subscription identifiers, customer/plan references, and lifecycle dates. It prevents missing or duplicate subscription records, validates controlled formats such as currency codes and billing statuses, and applies lifecycle integrity rules to ensure subscriptions have coherent start/end dates and status-driven end-date requirements. Together, these checks prevent incorrect entitlements, broken billing flows, and inaccurate MRR/ARR reporting caused by incomplete or inconsistent subscription state.

saas_subscriptions_data_contract.yml

dataset
variables:
  FRESHNESS_HOURS:
    default: 24

checks:
  - schema:
      allow_extra_columns: false
      allow_other_column_order: false
  - row_count:
      threshold:
        must_be_greater_than: 0
  - freshness:
      column: start_date
      threshold:
        unit: hour
        must_be_less_than_or_equal: ${var.FRESHNESS_HOURS}
  - failed_rows:
      name: "Subscription start_date must not be after end_date"
      expression: end_date IS NOT NULL AND start_date > end_date
  - failed_rows:
      name: "Cancelled or expired subscriptions must have an end_date"
      expression: (billing_status IN ('CANCELLED', 'EXPIRED') AND end_date IS NULL)
  - failed_rows:
      name: "Active subscriptions should not have an end_date in the past"
      expression: (billing_status = 'ACTIVE'

columns:
  - name: subscription_id
    data_type: varchar
    checks:
      - missing:
      - duplicate:
  - name: customer_id
    data_type: varchar
    checks:
      - missing:
  - name: plan_id
    data_type: varchar
    checks:
      - missing:
  - name: start_date
    data_type: date
    checks:
      - missing:
  - name: end_date
    data_type: date
  - name: billing_status
    data_type: varchar
    checks:
      - missing:
      - invalid:
          name: "Allowed billing statuses"
          valid_values:
            - TRIALING
            - ACTIVE
            - PAST_DUE
            - CANCELLED
            - EXPIRED
  - name: currency
    data_type: varchar
    checks:
      - missing:
      - invalid:
          name: "Currency must be ISO-4217-like (3 uppercase letters)"
          valid_format:
            name: ISO-4217 code
            regex: "^[A-Z]{3}$"

Data contract description

This data contract enforces schema stability, a 24-hour freshness SLA, and required subscription identifiers, customer/plan references, and lifecycle dates. It prevents missing or duplicate subscription records, validates controlled formats such as currency codes and billing statuses, and applies lifecycle integrity rules to ensure subscriptions have coherent start/end dates and status-driven end-date requirements. Together, these checks prevent incorrect entitlements, broken billing flows, and inaccurate MRR/ARR reporting caused by incomplete or inconsistent subscription state.

saas_subscriptions_data_contract.yml

dataset
variables:
  FRESHNESS_HOURS:
    default: 24

checks:
  - schema:
      allow_extra_columns: false
      allow_other_column_order: false
  - row_count:
      threshold:
        must_be_greater_than: 0
  - freshness:
      column: start_date
      threshold:
        unit: hour
        must_be_less_than_or_equal: ${var.FRESHNESS_HOURS}
  - failed_rows:
      name: "Subscription start_date must not be after end_date"
      expression: end_date IS NOT NULL AND start_date > end_date
  - failed_rows:
      name: "Cancelled or expired subscriptions must have an end_date"
      expression: (billing_status IN ('CANCELLED', 'EXPIRED') AND end_date IS NULL)
  - failed_rows:
      name: "Active subscriptions should not have an end_date in the past"
      expression: (billing_status = 'ACTIVE'

columns:
  - name: subscription_id
    data_type: varchar
    checks:
      - missing:
      - duplicate:
  - name: customer_id
    data_type: varchar
    checks:
      - missing:
  - name: plan_id
    data_type: varchar
    checks:
      - missing:
  - name: start_date
    data_type: date
    checks:
      - missing:
  - name: end_date
    data_type: date
  - name: billing_status
    data_type: varchar
    checks:
      - missing:
      - invalid:
          name: "Allowed billing statuses"
          valid_values:
            - TRIALING
            - ACTIVE
            - PAST_DUE
            - CANCELLED
            - EXPIRED
  - name: currency
    data_type: varchar
    checks:
      - missing:
      - invalid:
          name: "Currency must be ISO-4217-like (3 uppercase letters)"
          valid_format:
            name: ISO-4217 code
            regex: "^[A-Z]{3}$"

Data contract description

This data contract enforces schema stability, a 24-hour freshness SLA, and required subscription identifiers, customer/plan references, and lifecycle dates. It prevents missing or duplicate subscription records, validates controlled formats such as currency codes and billing statuses, and applies lifecycle integrity rules to ensure subscriptions have coherent start/end dates and status-driven end-date requirements. Together, these checks prevent incorrect entitlements, broken billing flows, and inaccurate MRR/ARR reporting caused by incomplete or inconsistent subscription state.

saas_subscriptions_data_contract.yml

dataset
variables:
  FRESHNESS_HOURS:
    default: 24

checks:
  - schema:
      allow_extra_columns: false
      allow_other_column_order: false
  - row_count:
      threshold:
        must_be_greater_than: 0
  - freshness:
      column: start_date
      threshold:
        unit: hour
        must_be_less_than_or_equal: ${var.FRESHNESS_HOURS}
  - failed_rows:
      name: "Subscription start_date must not be after end_date"
      expression: end_date IS NOT NULL AND start_date > end_date
  - failed_rows:
      name: "Cancelled or expired subscriptions must have an end_date"
      expression: (billing_status IN ('CANCELLED', 'EXPIRED') AND end_date IS NULL)
  - failed_rows:
      name: "Active subscriptions should not have an end_date in the past"
      expression: (billing_status = 'ACTIVE'

columns:
  - name: subscription_id
    data_type: varchar
    checks:
      - missing:
      - duplicate:
  - name: customer_id
    data_type: varchar
    checks:
      - missing:
  - name: plan_id
    data_type: varchar
    checks:
      - missing:
  - name: start_date
    data_type: date
    checks:
      - missing:
  - name: end_date
    data_type: date
  - name: billing_status
    data_type: varchar
    checks:
      - missing:
      - invalid:
          name: "Allowed billing statuses"
          valid_values:
            - TRIALING
            - ACTIVE
            - PAST_DUE
            - CANCELLED
            - EXPIRED
  - name: currency
    data_type: varchar
    checks:
      - missing:
      - invalid:
          name: "Currency must be ISO-4217-like (3 uppercase letters)"
          valid_format:
            name: ISO-4217 code
            regex: "^[A-Z]{3}$"

How to Enforce Data Contracts with Soda

Embed data quality through data contracts at any point in your pipeline.

Embed data quality through data contracts at any point in your pipeline.

# pip install soda-{data source} for other data sources

# pip install soda-{data source} for other data sources

pip install soda-postgress

pip install soda-postgress

# verify the contract locally against a data source

# verify the contract locally against a data source

soda contract verify -c contract.yml -ds ds_config.yml

soda contract verify -c contract.yml -ds ds_config.yml

# publish and schedule the contract with Soda Cloud

# publish and schedule the contract with Soda Cloud

soda contract publish -c contract.yml -sc sc_config.yml

soda contract publish -c contract.yml -sc sc_config.yml

Check out the CLI documentation to learn more.

Check out the CLI documentation to learn more.

How to Automatically Create Data Contracts.
In one Click.

Automatically write and publish data contracts using Soda's AI-powered data contract copilot.

Make data contracts work in production

Business knows what good data looks like. Engineering knows how to deliver it at scale. Soda unites both, turning governance expectations into executable contracts.

Make data contracts work in production

Business knows what good data looks like. Engineering knows how to deliver it at scale. Soda unites both, turning governance expectations into executable contracts.

Make data contracts work in production

Business knows what good data looks like. Engineering knows how to deliver it at scale. Soda unites both, turning governance expectations into executable contracts.

4.4 of 5

Start trusting your data. Today.

Find, understand, and fix any data quality issue in seconds.
From table to record-level.

Trusted by

4.4 of 5

Start trusting your data. Today.

Find, understand, and fix any data quality issue in seconds.
From table to record-level.

Trusted by

4.4 of 5

Start trusting your data. Today.

Find, understand, and fix any data quality issue in seconds.
From table to record-level.

Trusted by