version: 2

models:

  - name: STREAMS_COMPLETIONS_BY_TRACK_PLAYLIST_COUNTRY_FEED_DISTRIBUTOR_DAILY_RECENT_DBT
    description:
      A table containing number of streams and metadata on a playlist / country level.
    tests:
      - unique:
          column_name: "concat(track_id, '-',  playlist_id, '-',  country_code, '-', feed_id, '-', distributor, '-', download_activity_date)"
    columns:
      - name: distributor
        tests:
          - not_null
      - name: track_id
        tests:
          - not_null
      - name: playlist_id
        tests:
          - not_null
      - name: country_code
        tests:
          - not_null
      - name: feed_id
        tests:
          - not_null
      - name: download_activity_date
        tests:
          - not_null
      - name: store_playlist_id
        tests:
          - not_null
      - name: label_id
      - name: store_id
        tests:
          - not_null
      - name: product_id
        tests:
          - not_null
      - name: isrc
        tests:
          - not_null
      - name: playlist_name
      - name: playlist_url
        tests:
          - not_null
      - name: playlist_image
      - name: playlist_type_name
      - name: streams
        tests:
          - not_null
      - name: completions

  - name: STREAMS_COMPLETIONS_BY_TRACK_PLAYLIST_COUNTRY_FEED_DISTRIBUTOR_DAILY_HISTORY_DBT
    config:
      tags: history
    description:
      A table containing number of streams and metadata on a playlist / country level.
    tests:
      - unique:
          column_name: "concat(track_id, '-',  playlist_id, '-',  country_code, '-', feed_id, '-', distributor, '-', download_activity_date)"
    columns:
      - name: distributor
        tests:
          - not_null
      - name: track_id
        tests:
          - not_null
      - name: playlist_id
        tests:
          - not_null
      - name: country_code
        tests:
          - not_null
      - name: feed_id
        tests:
          - not_null
      - name: download_activity_date
        tests:
          - not_null
      - name: store_playlist_id
        tests:
          - not_null
      - name: label_id
      - name: store_id
        tests:
          - not_null
      - name: product_id
        tests:
          - not_null
      - name: isrc
        tests:
          - not_null
      - name: playlist_name
      - name: playlist_url
        tests:
          - not_null
      - name: playlist_image
      - name: playlist_type_name
      - name: streams
        tests:
          - not_null
      - name: completions


  - name: STREAMS_COMPLETIONS_BY_TRACK_PLAYLIST_COUNTRY_FEED_DISTRIBUTOR_ROLLUP_HISTORY_DBT
    description:
      A table containing streams and completions for multiple time periods on a playlist / country level.
    tests:
      - unique:
          column_name: "concat(track_id, '-', playlist_id, '-', country_code, '-', feed_id, '-', distributor)"
    columns:
      - name: distributor
        tests:
          - not_null
      - name: track_id
        tests:
          - not_null
      - name: playlist_id
        tests:
          - not_null
      - name: country_code
        tests:
          - not_null
      - name: feed_id
        tests:
          - not_null
      - name: store_playlist_id
        tests:
          - not_null
      - name: label_id
        tests:
          - not_null
      - name: subaccount_id
      - name: store_id
        tests:
          - not_null
      - name: product_id
        tests:
          - not_null
      - name: isrc
        tests:
          - not_null
      - name: streams_all_time
        tests:
          - not_null
      - name: streams_365_days
        tests:
          - not_null
      - name: streams_183_days
        tests:
          - not_null
      - name: streams_28_days
        tests:
          - not_null
      - name: streams_7_days
        tests:
          - not_null
      - name: completions_all_time
        tests:
          - not_null
      - name: completions_365_days
        tests:
          - not_null
      - name: completions_183_days
        tests:
          - not_null
      - name: completions_28_days
        tests:
          - not_null
      - name: completions_7_days
        tests:
          - not_null
      - name: completions_1_day
        tests:
          - not_null
  - name: STREAMS_COMPLETIONS_BY_TRACK_PLAYLIST_COUNTRY_FEED_DISTRIBUTOR_ROLLUP_HISTORY_PRODUCT_TRANSFER_DBT
    config:
      tags: ['product_transfer']
    description:
      A table containing streams and completions for multiple time periods on a playlist / country level.
      One row per (track_id, playlist_id, country_code, feed_id, distributor, label_id, subaccount_id),
      where label_id / subaccount_id come from PRODUCT_OWNERSHIP_ACCESS.
    tests:
      - unique:
          column_name: "concat(track_id, '-', playlist_id, '-', country_code, '-', feed_id, '-', distributor, '-', coalesce(label_id, -1), '-', coalesce(subaccount_id, -1))"
    columns:
      - name: distributor
        tests:
          - not_null
      - name: track_id
        tests:
          - not_null
      - name: playlist_id
        tests:
          - not_null
      - name: country_code
        tests:
          - not_null
      - name: feed_id
        tests:
          - not_null
      - name: store_playlist_id
        tests:
          - not_null
      - name: label_id
        tests:
          - not_null
      - name: subaccount_id
      - name: store_id
        tests:
          - not_null
      - name: product_id
        tests:
          - not_null
      - name: isrc
        tests:
          - not_null
      - name: streams_all_time
        tests:
          - not_null
      - name: streams_365_days
        tests:
          - not_null
      - name: streams_183_days
        tests:
          - not_null
      - name: streams_28_days
        tests:
          - not_null
      - name: streams_7_days
        tests:
          - not_null
      - name: completions_all_time
        tests:
          - not_null
      - name: completions_365_days
        tests:
          - not_null
      - name: completions_183_days
        tests:
          - not_null
      - name: completions_28_days
        tests:
          - not_null
      - name: completions_7_days
        tests:
          - not_null
      - name: completions_1_day
        tests:
          - not_null

