Retail Orders

Retail Orders

Data Contract Template

Data Contract Template

Ensure data from retail orders is fresh, complete, and reliable before it is used for revenue reporting, fulfillment tracking, logistics analytics, and customer order accuracy.

retail_orders_data_contract.yml

dataset
checks:
  - schema: {}
  - freshness:
      column: created_at
      threshold:
        unit: hour
        must_be_less_than_or_equal: 24
columns:
  - name: order_id
    data_type: string
    checks:
      - missing:
          name: No missing value
  - name: product_id
    data_type: string
    checks:
      - missing:
          name: No missing values
  - name: customer_id
    data_type: string
    checks:
      - missing:
          name: No missing values
  - name: order_quantity
    data_type: integer
    checks:
      - missing:
      - invalid:
          name: Positive quantity
          valid_min: 1
  - name: discount
    data_type: float
    checks:
      - invalid:
          name: Positive quantity
          valid_min: 1
  - name: discount_currency
    data_type: string
    checks:
      - invalid:
          name: Allowed currency is USD
          valid_values:
            - usd
  - name: billing_address
    data_type: string
    checks:
      - missing:
  - name: shipping_address
    data_type: string
    checks:
      - missing:
  - name: payment_method
    data_type: string
    checks:
      - missing:
      - invalid:
          name: Allowed payment methods
          valid_values:
            - cash
            - credit_card
            - transfer
  - name: order_date
    data_type: dateTime
    checks:
      - missing:
  - name: ship_date
    data_type: dateTime
    checks:
      - missing:
  - name: country_code
    data_type: string
    checks:
      - missing:
      - invalid:
          name: Two-letter country code
          valid_format:
            regex: ^[A-Za-z]{2}$
            name: Exactly two letters
  - name: total_order_value
    data_type: float
    checks:
      - missing:
  - name: created_at
    data_type: dateTime
    checks:
      - missing

retail_orders_data_contract.yml

dataset
checks:
  - schema: {}
  - freshness:
      column: created_at
      threshold:
        unit: hour
        must_be_less_than_or_equal: 24
columns:
  - name: order_id
    data_type: string
    checks:
      - missing:
          name: No missing value
  - name: product_id
    data_type: string
    checks:
      - missing:
          name: No missing values
  - name: customer_id
    data_type: string
    checks:
      - missing:
          name: No missing values
  - name: order_quantity
    data_type: integer
    checks:
      - missing:
      - invalid:
          name: Positive quantity
          valid_min: 1
  - name: discount
    data_type: float
    checks:
      - invalid:
          name: Positive quantity
          valid_min: 1
  - name: discount_currency
    data_type: string
    checks:
      - invalid:
          name: Allowed currency is USD
          valid_values:
            - usd
  - name: billing_address
    data_type: string
    checks:
      - missing:
  - name: shipping_address
    data_type: string
    checks:
      - missing:
  - name: payment_method
    data_type: string
    checks:
      - missing:
      - invalid:
          name: Allowed payment methods
          valid_values:
            - cash
            - credit_card
            - transfer
  - name: order_date
    data_type: dateTime
    checks:
      - missing:
  - name: ship_date
    data_type: dateTime
    checks:
      - missing:
  - name: country_code
    data_type: string
    checks:
      - missing:
      - invalid:
          name: Two-letter country code
          valid_format:
            regex: ^[A-Za-z]{2}$
            name: Exactly two letters
  - name: total_order_value
    data_type: float
    checks:
      - missing:
  - name: created_at
    data_type: dateTime
    checks:
      - missing

Data contract description

This data contract enforces schema stability, a 24-hour freshness SLA on created_at, and required identifiers, timestamps, and address fields for retail order processing. It validates positive order quantities, restricts discount_currency to USD, limits payment_method to approved values, and enforces two-letter country code formatting. These checks prevent incomplete or malformed orders from breaking fulfillment, revenue reporting, and logistics analytics.

retail_orders_data_contract.yml

dataset
checks:
  - schema: {}
  - freshness:
      column: created_at
      threshold:
        unit: hour
        must_be_less_than_or_equal: 24
columns:
  - name: order_id
    data_type: string
    checks:
      - missing:
          name: No missing value
  - name: product_id
    data_type: string
    checks:
      - missing:
          name: No missing values
  - name: customer_id
    data_type: string
    checks:
      - missing:
          name: No missing values
  - name: order_quantity
    data_type: integer
    checks:
      - missing:
      - invalid:
          name: Positive quantity
          valid_min: 1
  - name: discount
    data_type: float
    checks:
      - invalid:
          name: Positive quantity
          valid_min: 1
  - name: discount_currency
    data_type: string
    checks:
      - invalid:
          name: Allowed currency is USD
          valid_values:
            - usd
  - name: billing_address
    data_type: string
    checks:
      - missing:
  - name: shipping_address
    data_type: string
    checks:
      - missing:
  - name: payment_method
    data_type: string
    checks:
      - missing:
      - invalid:
          name: Allowed payment methods
          valid_values:
            - cash
            - credit_card
            - transfer
  - name: order_date
    data_type: dateTime
    checks:
      - missing:
  - name: ship_date
    data_type: dateTime
    checks:
      - missing:
  - name: country_code
    data_type: string
    checks:
      - missing:
      - invalid:
          name: Two-letter country code
          valid_format:
            regex: ^[A-Za-z]{2}$
            name: Exactly two letters
  - name: total_order_value
    data_type: float
    checks:
      - missing:
  - name: created_at
    data_type: dateTime
    checks:
      - missing

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-postgres

pip install soda-postgres

# 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.

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