Skip to main content
version: 2

models:
  - name: dim_order_discounts
    description: >
      Order discount dimension with discount types, codes, and values. Grain: One row per sm_order_discount_key. No canonical date; _synced_at is a freshness timestamp (not for analysis). Critical filters: source_system for platform-specific discount representation. Key joins: dim_order_lines via sm_order_line_key (many:1); dim_orders via sm_order_key (many:1).
    columns:
      - name: _synced_at
        description: >
          UTC timestamp when SourceMedium last synced the row. Freshness indicator only; not for time-series analysis.

      - name: discount_code
        description: >
          The case-insensitive discount code that customers use at checkout.

      - name: discount_index
        description: >
          An ordered index that can be used to identify the discount application and indicate the precedence of the discount application for calculations.

      - name: discount_line_entity
        description: >
          The entity that the discount is applied to, such as an order line or a shipping line.

      - name: discount_type
        description: >
          The type of discount, such as an automatic discount, a discount code, or a manual discount.

      - name: discounts
        description: >
          The amount of the discount applied to the discount entity.

      - name: order_currency_code
        description: >
          The three-letter code (ISO 4217 format) for the currency used for the tender transaction.

      - name: order_id
        description: >
          Platform order identifier. Not globally unique across stores; pair with `smcid` and `source_system` when needed for scoping.

      - name: order_line_id
        description: >
          The ID of the order line.

      - name: sm_order_discount_key
        description: >
          The unique discount key created by SourceMedium that can be used to join discount dimensions to related tables.

      - name: sm_order_key
        description: >
          Stable SourceMedium order key. Unique per order. Key joins: `obt_order_lines` (1:many via `sm_order_key`); `dim_customers` (many:1 via `sm_customer_key`). Platform caveat: TikTok Shop coverage may be limited.

      - name: sm_order_line_key
        description: >
          Stable SourceMedium order line key. Unique per line. Key joins: `dim_order_lines` (1:1); `dim_orders` (many:1 via `sm_order_key`). Platform caveat: TikTok Shop coverage may be limited.

      - name: sm_store_id
        description: >
          SourceMedium's unique store identifier. For Shopify stores, derived from the myshopify.com domain; for other platforms (Amazon, TikTok Shop, Walmart.com), uses platform-specific identifiers.

      - name: source_system
        description: >
          Originating platform for the record (e.g., Shopify, Amazon, TikTok Shop, Chargebee). Used for platform‑specific behavior and coverage.