version: 2

models:

  - name: STREAMS_BY_TRACK_COUNTRY_FEED_DISTRIBUTOR_DAILY_RECENT_DBT
    description:
      A table containing number of streams, source of streams, skips and saves metrics for tracks on a
      date / country / feedid level
    tests:
      - unique:
          column_name: "concat(track_id, '-', download_activity_date, '-', country_code, '-', feed_id, '-', distributor)"
    columns:
      - name: distributor
        tests:
          - not_null
      - name: track_id
        tests:
          - not_null
      - name: download_activity_date
        tests:
          - not_null
      - name: country_code
      - name: feed_id
        tests:
          - not_null
      - name: store_id
        tests:
          - not_null
      - name: product_id
        tests:
          - not_null
      - name: label_id
      - name: isrc
        tests:
          - not_null
      - name: streams
        tests:
          - not_null
      - name: skips
        description:
          This value is lower than the value for `skips` in `SUMMARY_METRICS_BY_ISRC_DBT` because of the
          join on `COUNTRY` with `STAGING_RAW_SPOTIFY_AGGREGATED_STREAMS`.
      - name: saves
        description:
          This value is lower than the value for `saves` in `SUMMARY_METRICS_BY_ISRC_DBT` because of the
          join on `COUNTRY` with `STAGING_RAW_SPOTIFY_AGGREGATED_STREAMS`.
      - name: streams_passive
        tests:
          - not_null
      - name: streams_active
        tests:
          - not_null
      - name: streams_collection
        tests:
          - not_null
      - name: sub_type_subscription
        tests:
          - not_null
      - name: sub_type_adsupported
        tests:
          - not_null
      - name: sub_type_midtier
        tests:
          - not_null

  - name: STREAMS_BY_TRACK_COUNTRY_FEED_DISTRIBUTOR_DAILY_HISTORY_DBT
    config:
      tags: history
    description:
      A table containing number of streams, source of streams, skips and saves metrics for tracks on a
      date / country / feedid level
    tests:
      - unique:
          column_name: "concat(track_id, '-', download_activity_date, '-', country_code, '-', feed_id, '-', distributor)"
    columns:
      - name: distributor
        tests:
          - not_null
      - name: track_id
        tests:
          - not_null
      - name: download_activity_date
        tests:
          - not_null
      - name: country_code
      - name: feed_id
        tests:
          - not_null
      - name: store_id
        tests:
          - not_null
      - name: product_id
        tests:
          - not_null
      - name: label_id
      - name: isrc
        tests:
          - not_null
      - name: streams
        tests:
          - not_null
      - name: skips
        description:
          This value is lower than the value for `skips` in `SUMMARY_METRICS_BY_ISRC_DBT` because of the
          join on `COUNTRY` with `STAGING_RAW_SPOTIFY_AGGREGATED_STREAMS`.
      - name: saves
        description:
          This value is lower than the value for `saves` in `SUMMARY_METRICS_BY_ISRC_DBT` because of the
          join on `COUNTRY` with `STAGING_RAW_SPOTIFY_AGGREGATED_STREAMS`.
      - name: streams_passive
        tests:
          - not_null
      - name: streams_active
        tests:
          - not_null
      - name: streams_collection
        tests:
          - not_null
      - name: sub_type_subscription
        tests:
          - not_null
      - name: sub_type_adsupported
        tests:
          - not_null
      - name: sub_type_midtier
        tests:
          - not_null
