version: 2
models:
  - name: FANS_BY_ARTIST_ACCOUNT_OTHER_ARTIST_DBT
    description: '{{ doc("FANS_BY_ARTIST_ACCOUNT_OTHER_ARTIST_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - GLOBAL_PARTICIPANT_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID_LISTENED_TOGETHER
    columns:
      - name: GLOBAL_PARTICIPANT_ID
        description: Global Participant ID
        data_tests:
          - not_null
      - name: VENDOR_ID
        description: Vendor ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        description: Subaccount ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID_LISTENED_TOGETHER
        description: Global Participant ID of the Artist listened together with the main Global Participant
        data_tests:
          - not_null
      - name: FANS_SHARE
        description: Share of fans who have have listened to both Global Participant and Global Participant Listened Together
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '>= 0'
  - name: FANS_BY_ARTIST_ACCOUNT_OTHER_ARTIST_COUNTRY_DBT
    description: '{{ doc("FANS_BY_ARTIST_ACCOUNT_OTHER_ARTIST_COUNTRY_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - GLOBAL_PARTICIPANT_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID_LISTENED_TOGETHER
            - COUNTRY_ISO2
    columns:
      - name: GLOBAL_PARTICIPANT_ID
        description: Global Participant ID
        data_tests:
          - not_null
      - name: VENDOR_ID
        description: Vendor ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        description: Subaccount ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID_LISTENED_TOGETHER
        description: Global Participant ID of the Artist listened together with the main Global Participant. Can be null if the top 10 listened together artist has no fans that listened in this country
      - name: COUNTRY_ISO2
        description: Country code in ISO2 format
        data_tests:
          - not_null
      - name: FANS_COUNT
        description: Number of fans who have have listened to both Global Participant and Global Participant Listened Together
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '>= 0'
      - name: TOTAL_FANS_COUNT
        description: Number of total fans for country
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '>= FANS_COUNT'
      - name: FANS_SHARE
        description: Share of fans who have have listened to both Global Participant and Global Participant Listened Together
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '>= 0'
  - name: GLOBAL_FANS_BY_ARTIST_OTHER_ARTIST_DBT
    description: '{{ doc("GLOBAL_FANS_BY_ARTIST_OTHER_ARTIST_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - GLOBAL_PARTICIPANT_ID
            - GLOBAL_PARTICIPANT_ID_LISTENED_TOGETHER
    columns:
      - name: GLOBAL_PARTICIPANT_ID
        description: Global Participant ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID_LISTENED_TOGETHER
        description: Global Participant ID of the Artist listened together with the main Global Participant
        data_tests:
          - not_null
      - name: FANS_SHARE
        description: Share of fans who have have listened to both Global Participant and Global Participant Listened Together
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '>= 0'
  - name: GLOBAL_FANS_BY_ARTIST_OTHER_ARTIST_COUNTRY_DBT
    description: '{{ doc("GLOBAL_FANS_BY_ARTIST_OTHER_ARTIST_COUNTRY_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - GLOBAL_PARTICIPANT_ID
            - GLOBAL_PARTICIPANT_ID_LISTENED_TOGETHER
            - COUNTRY_ISO2
    columns:
      - name: GLOBAL_PARTICIPANT_ID
        description: Global Participant ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID_LISTENED_TOGETHER
        description: Global Participant ID of the Artist listened together with the main Global Participant. Can be null if the top 10 listened together artist has no fans that listened in this country
      - name: COUNTRY_ISO2
        description: Country code in ISO2 format
        data_tests:
          - not_null
      - name: FANS_COUNT
        description: Number of fans who have have listened to both Global Participant and Global Participant Listened Together
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '>= 0'
      - name: TOTAL_FANS_COUNT
        description: Number of total fans for country
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '>= FANS_COUNT'
      - name: FANS_SHARE
        description: Share of fans who have have listened to both Global Participant and Global Participant Listened Together
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '>= 0'


  - name: INT_FAN_LISTENED_TO_ARTIST
    description: '{{ doc("INT_FAN_LISTENED_TO_ARTIST") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - GLOBAL_PARTICIPANT_ID
            - FAN_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: GLOBAL_PARTICIPANT_ID
        description: Global Participant ID
        data_tests:
          - not_null
      - name: FAN_ID
        description: Fansifter fan identifier
        data_tests:
          - not_null
