version: 2

models:

  - name: STREAMS_BY_TRACK_COUNTRY_REGION_FEED_DISTRIBUTOR_ROLLUP_DBT
    description:
      A table containing number of streams for the last 7 days and the previous week on a track /
      region / feed level
    tests:
      - unique:
          column_name: "concat(track_id, '-',  country_code, '-',  orchard_region_code, '-',  feed_id, '-',  distributor)"
    columns:
      - name: distributor
        tests:
          - not_null
      - name: track_id
        tests:
          - not_null
      - name: country_code
        tests:
          - not_null
      - name: orchard_region_code
        tests:
          - not_null
      - name: feed_id
        tests:
          - not_null
      - name: product_id
        tests:
          - not_null
      - name: label_id
      - name: isrc
        tests:
          - not_null
      - name: streams_7_days
        tests:
          - not_null
      - name: streams_7_days_prev
        tests:
          - not_null
  - name: STREAMS_BY_TRACK_COUNTRY_REGION_FEED_DISTRIBUTOR_ROLLUP_PRODUCT_TRANSFER_DBT
    config:
      tags: ['product_transfer']
    description:
      A table containing number of streams for the last 7 days and the previous week on a track /
      region / feed level. One row per (track, country, region, feed, distributor, store, product,
      label_id, subaccount_id), where label_id / subaccount_id come from PRODUCT_OWNERSHIP_ACCESS.
    tests:
      - unique:
          column_name: "concat(track_id, '-',  country_code, '-',  orchard_region_code, '-',  feed_id, '-',  distributor, '-', store_id, '-', product_id, '-', coalesce(label_id, -1), '-', coalesce(subaccount_id, -1))"
    columns:
      - name: distributor
        tests:
          - not_null
      - name: track_id
        tests:
          - not_null
      - name: country_code
        tests:
          - not_null
      - name: orchard_region_code
        tests:
          - not_null
      - name: feed_id
        tests:
          - not_null
      - name: product_id
        tests:
          - not_null
      - name: label_id
      - name: subaccount_id
      - name: isrc
        tests:
          - not_null
      - name: streams_7_days
        tests:
          - not_null
      - name: streams_7_days_prev
        tests:
          - not_null

