# DAS: the source, in its own words. An ODCS v3 data contract, one per table.
# The shop's order headers. The shop is a PostgreSQL database, which das-cli
# has no source type for, so there is no das source file beside this contract;
# the demo loads the table into DuckDB as stage.sales_orders.
apiVersion: v3.0.0
version: 1.0.0
kind: DataContract
id: shop__sales_orders
schema:
  - name: sales_orders
    physicalName: shop__sales_orders
    description: >
      One row per order a customer placed, online or in a store. The order's
      lines are in sales_order_lines.
    properties:
      - name: order_id
        logicalType: integer
        required: true
        primaryKey: true
        transformSourceObjects: [order_id]
        description: The shop's id for the order.
      - name: order_date
        logicalType: timestamp
        required: false
        transformSourceObjects: [order_date]
        description: >
          When the customer placed the order (event time), with time zone. The
          order's lines happened at this time too. Defaults to the insert time
          when the shop does not supply it.
      - name: order_status
        logicalType: string
        required: false
        transformSourceObjects: [order_status]
        description: >
          Where the order is in its lifecycle. Values in the data: Processing,
          Shipped, Delivered. New orders default to Pending.
      - name: ingested_at
        logicalType: timestamp
        required: true
        transformSourceObjects: [ingested_at]
        description: >
          When the row was written to this table (load time), set by the
          database. It is not when the order was placed: use order_date for
          that, and compare the two to tell an order that arrived late from one
          that is missing.
customProperties:
  - property: das.resource
    value: sales_orders
  - property: das.models
    value: historized,latest
