version: 2
models:
  - name: FANS_BY_ARTIST_ACCOUNT_ACQUISITION_COUNTRY_DAILY_DBT
    description: '{{ doc("FANS_BY_ARTIST_ACCOUNT_ACQUISITION_COUNTRY_DAILY_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - GLOBAL_PARTICIPANT_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - ACQUIRED_AT_DATE
            - COUNTRY_ISO2
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
      - dbt_utils.expression_is_true:
          expression: "DAILY_RUNNING_TOTAL_EMAIL_ELIGIBLE_FANS_COUNT <= DAILY_RUNNING_TOTAL_FANS_COUNT"
    columns:
      - name: VENDOR_ID
        description: Vendor ID from Orchard
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        description: Subaccount ID from Orchard
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        description: Global participant ID from Orchard
        data_tests:
          - not_null
      - name: ACQUIRED_AT_DATE
        description: Date representing fan acquisition
        data_tests:
          - not_null
      - name: COUNTRY_ISO2
        description: Country code in ISO2 format
        data_tests:
          - not_null
      - name: DAILY_RUNNING_TOTAL_FANS_COUNT
        description: Cumulative count of fans per day
        data_tests:
          - not_null
          - fans_count_equal_to_source_country_daily:
              value_column: "COUNTRY_ISO2"
              date_column: "ACQUIRED_AT_DATE"
      - name: DAILY_RUNNING_TOTAL_EMAIL_ELIGIBLE_FANS_COUNT
        description: Cumulative count of email eligible fans per day (forward-filled)
        data_tests:
          - not_null
  - name: GLOBAL_FANS_BY_ARTIST_ACQUISITION_COUNTRY_DAILY_DBT
    description: '{{ doc("GLOBAL_FANS_BY_ARTIST_ACQUISITION_COUNTRY_DAILY_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - GLOBAL_PARTICIPANT_ID
            - ACQUIRED_AT_DATE
            - COUNTRY_ISO2
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
      - dbt_utils.expression_is_true:
          expression: "DAILY_RUNNING_TOTAL_EMAIL_ELIGIBLE_FANS_COUNT <= DAILY_RUNNING_TOTAL_FANS_COUNT"
    columns:
      - name: GLOBAL_PARTICIPANT_ID
        description: Global participant ID from Orchard
        data_tests:
          - not_null
      - name: ACQUIRED_AT_DATE
        description: Date representing fan acquisition
        data_tests:
          - not_null
      - name: COUNTRY_ISO2
        description: Country code in ISO2 format
        data_tests:
          - not_null
      - name: DAILY_RUNNING_TOTAL_FANS_COUNT
        description: Cumulative count of fans per day
        data_tests:
          - not_null
          - global_fans_count_equal_to_source_country_daily:
              value_column: "COUNTRY_ISO2"
              date_column: "ACQUIRED_AT_DATE"
      - name: DAILY_RUNNING_TOTAL_EMAIL_ELIGIBLE_FANS_COUNT
        description: Cumulative count of email eligible fans per day (forward-filled)
        data_tests:
          - not_null
