models:
  - name: d_customer
    description: "Customer Dimension"
    columns:
      - name: customer_id
        description: "customer id"

      - name: first_name
        description: "First Name"

      - name: last_name
        description: "Last Name"

      - name: email
        description: "Email address"

      - name: gender
        description: "Gender - F/M"

      - name: dob
        description: "Date of birth"

  - name: d_product
    description: ""
    columns:
      - name: product_id
        description: ""

      - name: product_category_id
        description: ""
        tests:
          - not_null
          - relationships:
              to: ref('d_product_category')
              field: product_category_id

      - name: product_name
        description: ""

      - name: price
        description: ""

  - name: d_shipping
    description: ""
    columns:
      - name: shipping_id
        description: ""

      - name: customer_id
        description: ""
        tests:
          - not_null
          - relationships:
              to: ref('d_customer')
              field: customer_id

      - name: street
        description: ""

      - name: city
        description: ""

      - name: state
        description: ""

      - name: zipcode
        description: ""

  - name: d_product_category
    description: ""
    columns:
      - name: product_category_id
        description: ""

      - name: product_category_name
        description: ""

  - name: f_inventory
    description: ""
    columns:
      - name: product_id
        description: ""
        tests:
          - not_null
          - relationships:
              to: ref('d_product')
              field: product_id

      - name: product_category_id
        description: ""
        tests:
          - not_null
          - relationships:
              to: ref('d_product_category')
              field: product_category_id

      - name: quantity
        description: ""

      - name: last_shipped_quantity
        description: ""

      - name: last_order_date
        description: ""

      - name: as_of_date
        description: ""

  - name: f_order
    description: ""
    columns:
      - name: order_id
        description: ""

      - name: customer_id
        description: ""
        tests:
          - not_null
          - relationships:
              to: ref('d_customer')
              field: customer_id

      - name: shipping_id
        description: ""
        tests:
          - not_null
          - relationships:
              to: ref('d_shipping')
              field: shipping_id

      - name: product_id
        description: ""
        tests:
          - not_null
          - relationships:
              to: ref('d_product')
              field: product_id

      - name: product_category_id
        description: ""
        tests:
          - not_null
          - relationships:
              to: ref('d_product_category')
              field: product_category_id

      - name: units
        description: ""

      - name: price
        description: ""

      - name: order_date
        description: ""
metrics:
  - name: new_customers
    label: New Customers
    model: ref('d_customer')
    description: "The number of paid customers using the product"

    type: count
    sql: user_id # superfluous here, but shown as an example

    timestamp: signup_date
    time_grains: [day, week, month]

    dimensions:
      - plan
      - country

    filters:
      - field: is_paying
        operator: 'is'
        value: 'true'
      - field: lifetime_value
        operator: '>='
        value: '100'
      - field: company_name
        operator: '!='
        value: "'Acme, Inc'"
      - field: signup_date
        operator: '>='
        value: "'2020-01-01'"