Skip to content

data contracts

ghdrako edited this page Jul 12, 2026 · 4 revisions
data_contract:
  name: customer_orders_contract_v1
  description: >
    Defines the schema, quality, and delivery expectations for customer
    orders data produced by the transactional system and consumed by the
    analytics platform.
  version: 1.0
  producer: "ecommerce_app.orders_service"
  consumer: "analytics_team.orders_pipeline"

  schema:
    table: orders
    primary_key: order_id
    fields:
      - name: order_id
        type: STRING
        constraints: [NOT NULL, UNIQUE]
      - name: customer_id
        type: STRING
        constraints: [NOT NULL]
      - name: order_date
        type: TIMESTAMP
        constraints: [NOT NULL]
      - name: status
        type: STRING
        allowed_values: ["pending", "paid", "shipped", "canceled"]
      - name: total_amount
        type: DECIMAL(12,2)
        constraints: [NOT NULL, ">=0"]

  data_quality:
    expectations:
      - no_nulls: [order_id, customer_id, order_date, total_amount]
      - valid_enum: {status: ["pending", "paid", "shipped", "canceled"]}
      - currency: "total_amount must be >= 0"
    monitoring:
     freshness_sla: "Data available by 06:00 UTC daily"
     completeness: "At least 99.5% of transactions per day must be present"

  delivery:
    cadence: "daily batch, delivered by 06:00 UTC"
    storage_format: "Parquet"
    location: "s3://analytics-raw/orders/"
    partitioning: "by order_date (daily)"

  security_and_governance:
    pii_fields: [customer_id]
    handling:
      customer_id: "must be hashed in downstream gold models"
    access_control:
      roles:
        - name: analytics_read
          permissions: ["SELECT"]
        - name: finance_reporting
          permissions: ["SELECT", "EXPORT"]

  lifecycle:
    contract_valid_from: "2025-07-25"
    versioning_policy: >
      Minor changes (e.g. adding nullable columns) allowed with notification.
      Breaking changes require new contract version.
     deprecation_policy: "Deprecated versions supported for 90 days."

Test

Clone this wiki locally