version: 2
models:
  - name: INT_FAN_LOCATION_DBT
    description: '{{ doc("INT_FAN_LOCATION_DBT") }}'
    data_tests:
      - dbt_utils.expression_is_true:
          expression: "LENGTH(COUNTRY_ISO2) = 2"
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: COUNTRY_ISO2
        description: ISO2 Country Code
        data_tests:
          - not_null
      - name: REGION
        description: Name of the region
      - name: CITY
        description: Name of the fan city
      - name: POSTAL_CODE
        description: Postal code identifier
  - name: FAN_GENDER_DBT
    description: '{{ doc("FAN_GENDER_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: GENDER
        description: gender
        data_tests:
          - not_null
          - accepted_values:
              values: [ 'PREFER_NOT_TO_ANSWER', 'FEMALE', 'NON_BINARY_OTHER', 'MALE' ]
  - name: FAN_AGE_DBT
    description: '{{ doc("FAN_AGE_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
      - dbt_utils.expression_is_true:
          expression: "AGE_IN_YEARS >= 13"
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: AGE_IN_YEARS
        description: Fan age
        data_tests:
          - not_null
      - name: AGE_RANGE
        description: age range
        data_tests:
          - not_null
          - accepted_values:
              values: ['FROM_13_TO_17', 'FROM_18_TO_22','FROM_23_TO_30', 'FROM_31_TO_40', 'FROM_41_TO_51', 'FROM_52_TO_60', 'FROM_61']
  - name: FAN_ARTIST_CUSTOM_LIST_FIRST_LAST_EVENT_DBT
    description: '{{ doc("FAN_ARTIST_CUSTOM_LIST_FIRST_LAST_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
            - CUSTOM_LIST_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
      - dbt_utils.expression_is_true:
          expression: "custom_list_id is not null"
          config:
            where: "global_participant_id is null"
      - dbt_utils.expression_is_true:
          expression: "global_participant_id is not null"
          config:
            where: "custom_list_id is null"
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        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
        description: Global participant ID from Orchard
      - name: CUSTOM_LIST_ID
        description: Custom list ID from CRM
      - name: MIN_HAPPENED_AT
        description: Date representing when first event took place
        data_tests:
          - not_null
      - name: MAX_HAPPENED_AT
        description: Date representing when last event took place
        data_tests:
          - not_null
  - name: FAN_FIRST_LAST_EVENT_DBT
    description: '{{ doc("FAN_FIRST_LAST_EVENT_DBT") }}'
    data_tests:
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
          - unique
      - name: MIN_HAPPENED_AT
        description: Date representing when first event took place
        data_tests:
          - not_null
      - name: MAX_HAPPENED_AT
        description: Date representing when last event took place
        data_tests:
          - not_null
  - name: FAN_GENRE_DBT
    description: '{{ doc("FAN_GENRE_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: GENRE_LIST
        description: Array of preferred genre values from CRM
  - name: FAN_LANGUAGE_DBT
    description: '{{ doc("FAN_LANGUAGE_DBT") }}'
    config:
      materialized: table
      tags: ["python"]
      python_version: "3.11"
      packages:
        - "langcodes"
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: LANGUAGE
        description: Array of ISO 639-1 language codes normalized from CRM
      - name: LANGUAGE_ORIGINAL
        description: Raw unsplit preferred language string from CRM
  - name: FAN_DSP_DBT
    description: '{{ doc("FAN_DSP_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - DSP
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: DSP
        description: dsp name
        data_tests:
          - accepted_values:
              values: [ 'APPLE', 'SPOTIFY', 'DEEZER', 'YOUTUBE', 'AMAZON' ]
  - name: FAN_ARTIST_ACQUISITION_CHANNEL_DBT
    description: '{{ doc("FAN_ARTIST_ACQUISITION_CHANNEL_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        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
        description: Global participant ID from Orchard
        data_tests:
          - not_null
      - name: ACQUIRED_AT
        description: Date when acquisition took place
        data_tests:
          - not_null
      - name: ACQUISITION_CAMPAIGN
        description: campaign
        data_tests:
          - not_null
      - name: ACQUISITION_CAMPAIGN_ID
        description: campaign id
        data_tests:
          - not_null
      - name: CAMPAIGN_CATEGORY
        description: Campaign category
        data_tests:
          - accepted_values:
              values: [ 'SMF_BESPOKE_ACTIVATION',
                        'SMF_UNCATEGORIZED',
                        'SMF_PLAYLIST_GENERATOR_SPOTIFY_LIBRARY_SCAN',
                        'SMF_PLAYLIST_GENERATOR_QUIZ',
                        'SMF_SOCIAL_SIGNUP_FORM_COMBO',
                        'SMF_NEWSLETTER_SIGNUP',
                        'SMF_FAN_CARD_ACTIVATION',
                        'SMF_GENERAL_PRESAVE',
                        'SMF_GIVEAWAY' ]
      - name: ACQUISITION_CHANNEL
        description: channel
        data_tests:
          - not_null
          - accepted_values:
              values: [ 'WYNG',
                        'FILE_UPLOAD_TOOL',
                        'SMF_BESPOKE_ACTIVATION',
                        'SMF_UNCATEGORIZED',
                        'SMF_PLAYLIST_GENERATOR_SPOTIFY_LIBRARY_SCAN',
                        'SMF_PLAYLIST_GENERATOR_QUIZ',
                        'SMF_SOCIAL_SIGNUP_FORM_COMBO',
                        'SMF_NEWSLETTER_SIGNUP',
                        'SMF_FAN_CARD_ACTIVATION',
                        'SMF_GENERAL_PRESAVE',
                        'SMF_GIVEAWAY',
                        'MAKE_THE_LINK',
                        'TUNESPEAK',
                        'SHOPIFY',
                        'MIGRATION',
                        'APPRECIATION_ENGINE',
                        'TICKETING',
                        'FEATURE_FM',
                        'SPOTIFY_SONY_MUSIC_NOW',
                        'PREVIOUS_MAILING_LIST',
                        'SMS_CAMPAIGNS',
                        'SEATED_LIST',
                        'BANDSINTOWN_LIST',
                        'LINKFIRE',
                        'MAESTRO_LIST',
                        'WEBSITE',
                        'PAST_PURCHASERS',
                        'SQWAD',
                        'LEVELLR',
                        'EVENT_SHOP',
                        'MEDALLION',
                        'INTERNAL_SONY_LIST_TRANSFER',
                        'SONGWHIP_PRE_SAVE',
                        'SONGWHIP_EXCLUSIVE_CONTENT']
              where: "ACQUISITION_CHANNEL NOT LIKE 'ROSALIA_%'"
  - name: GLOBAL_FAN_ARTIST_ACQUISITION_CHANNEL_DBT
    description: '{{ doc("GLOBAL_FAN_ARTIST_ACQUISITION_CHANNEL_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        description: Global participant ID from Orchard
        data_tests:
          - not_null
      - name: ACQUIRED_AT
        description: Date when acquisition took place
        data_tests:
          - not_null
      - name: ACQUISITION_CAMPAIGN
        description: campaign
        data_tests:
          - not_null
      - name: ACQUISITION_CAMPAIGN_ID
        description: campaign id
        data_tests:
          - not_null
      - name: CAMPAIGN_CATEGORY
        description: Campaign category
        data_tests:
          - accepted_values:
              values: [ 'SMF_BESPOKE_ACTIVATION',
                        'SMF_UNCATEGORIZED',
                        'SMF_PLAYLIST_GENERATOR_SPOTIFY_LIBRARY_SCAN',
                        'SMF_PLAYLIST_GENERATOR_QUIZ',
                        'SMF_SOCIAL_SIGNUP_FORM_COMBO',
                        'SMF_NEWSLETTER_SIGNUP',
                        'SMF_FAN_CARD_ACTIVATION',
                        'SMF_GENERAL_PRESAVE',
                        'SMF_GIVEAWAY' ]
      - name: ACQUISITION_CHANNEL
        description: channel
        data_tests:
          - not_null
          - accepted_values:
              values: [ 'WYNG',
                        'FILE_UPLOAD_TOOL',
                        'SMF_BESPOKE_ACTIVATION',
                        'SMF_UNCATEGORIZED',
                        'SMF_PLAYLIST_GENERATOR_SPOTIFY_LIBRARY_SCAN',
                        'SMF_PLAYLIST_GENERATOR_QUIZ',
                        'SMF_SOCIAL_SIGNUP_FORM_COMBO',
                        'SMF_NEWSLETTER_SIGNUP',
                        'SMF_FAN_CARD_ACTIVATION',
                        'SMF_GENERAL_PRESAVE',
                        'SMF_GIVEAWAY',
                        'MAKE_THE_LINK',
                        'TUNESPEAK',
                        'SHOPIFY',
                        'MIGRATION',
                        'APPRECIATION_ENGINE',
                        'TICKETING',
                        'FEATURE_FM',
                        'SPOTIFY_SONY_MUSIC_NOW',
                        'PREVIOUS_MAILING_LIST',
                        'SMS_CAMPAIGNS',
                        'SEATED_LIST',
                        'BANDSINTOWN_LIST',
                        'LINKFIRE',
                        'MAESTRO_LIST',
                        'WEBSITE',
                        'PAST_PURCHASERS',
                        'SQWAD',
                        'LEVELLR',
                        'EVENT_SHOP',
                        'MEDALLION',
                        'INTERNAL_SONY_LIST_TRANSFER',
                        'SONGWHIP_PRE_SAVE',
                        'SONGWHIP_EXCLUSIVE_CONTENT']
              where: "ACQUISITION_CHANNEL NOT LIKE 'ROSALIA_%'"
  - name: FAN_CUSTOM_LIST_ACQUISITION_CHANNEL_DBT
    description: '{{ doc("FAN_CUSTOM_LIST_ACQUISITION_CHANNEL_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - CUSTOM_LIST_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        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: CUSTOM_LIST_ID
        description: Custom list id from CRM
        data_tests:
          - not_null
      - name: ACQUIRED_AT
        description: Date when acquisition took place
        data_tests:
          - not_null
      - name: CAMPAIGN_CATEGORY
        description: Campaign category
        data_tests:
          - accepted_values:
              values: [ 'SMF_BESPOKE_ACTIVATION',
                        'SMF_UNCATEGORIZED',
                        'SMF_PLAYLIST_GENERATOR_SPOTIFY_LIBRARY_SCAN',
                        'SMF_PLAYLIST_GENERATOR_QUIZ',
                        'SMF_SOCIAL_SIGNUP_FORM_COMBO',
                        'SMF_NEWSLETTER_SIGNUP',
                        'SMF_FAN_CARD_ACTIVATION',
                        'SMF_GENERAL_PRESAVE',
                        'SMF_GIVEAWAY' ]
      - name: ACQUISITION_CHANNEL
        description: channel
        data_tests:
          - not_null
          - accepted_values:
              values: [ 'WYNG',
                        'FILE_UPLOAD_TOOL',
                        'SMF_BESPOKE_ACTIVATION',
                        'SMF_UNCATEGORIZED',
                        'SMF_PLAYLIST_GENERATOR_SPOTIFY_LIBRARY_SCAN',
                        'SMF_PLAYLIST_GENERATOR_QUIZ',
                        'SMF_SOCIAL_SIGNUP_FORM_COMBO',
                        'SMF_NEWSLETTER_SIGNUP',
                        'SMF_FAN_CARD_ACTIVATION',
                        'SMF_GENERAL_PRESAVE',
                        'SMF_GIVEAWAY',
                        'MAKE_THE_LINK',
                        'TUNESPEAK',
                        'SHOPIFY',
                        'MIGRATION',
                        'APPRECIATION_ENGINE',
                        'TICKETING',
                        'FEATURE_FM',
                        'SPOTIFY_SONY_MUSIC_NOW',
                        'PREVIOUS_MAILING_LIST',
                        'SMS_CAMPAIGNS',
                        'SEATED_LIST',
                        'BANDSINTOWN_LIST',
                        'LINKFIRE',
                        'MAESTRO_LIST',
                        'WEBSITE',
                        'PAST_PURCHASERS',
                        'SQWAD',
                        'LEVELLR',
                        'EVENT_SHOP',
                        'MEDALLION',
                        'INTERNAL_SONY_LIST_TRANSFER',
                        'SONGWHIP_PRE_SAVE',
                        'SONGWHIP_EXCLUSIVE_CONTENT']
  - name: FAN_HEAVY_ROTATION_DBT
    description: '{{ doc("FAN_HEAVY_ROTATION_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan in CRM
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing The Orchard Global Participant
        data_tests:
          - not_null
      - name: HEAVY_ROTATION
        description: Heavy Rotation Status
        data_tests:
          - not_null
          - accepted_values:
              values:
                - 'IN'
                - 'NOT_IN'
  - name: FAN_SHOPIFY_SPEND_DBT
    description: '{{ doc("FAN_SHOPIFY_SPEND_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
            - CUSTOM_LIST_ID
      - dbt_utils.expression_is_true:
          expression: "custom_list_id is not null"
          config:
            where: "global_participant_id is null"
      - dbt_utils.expression_is_true:
          expression: "global_participant_id is not null"
          config:
            where: "custom_list_id is null"
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        description: Subaccount ID
        data_tests:
          - not_null
      - name: VENDOR_ID
        description: Vendor ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        description: Global participant ID from Orchard
      - name: CUSTOM_LIST_ID
        description: Custom list ID from CRM
      - name: ORDERS_COUNT
        description: Number of unique orders by a fan
        data_tests:
          - not_null
      - name: TOTAL_SPEND
        description: Monetary value
        data_tests:
          - not_null
  - name: GLOBAL_FAN_SHOPIFY_SPEND_DBT
    description: '{{ doc("GLOBAL_FAN_SHOPIFY_SPEND_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        description: Global participant ID from Orchard
      - name: ORDERS_COUNT
        description: Number of unique orders by a fan
        data_tests:
          - not_null
      - name: TOTAL_SPEND
        description: Monetary value
        data_tests:
          - not_null
  - name: ARTIST_MAX_SPEND_DBT
    description: '{{ doc("ARTIST_MAX_SPEND_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: SUBACCOUNT_ID
        description: Subaccount ID
        data_tests:
          - not_null
      - name: VENDOR_ID
        description: Vendor ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        description: Global participant ID from Orchard
        data_tests:
          - not_null
      - name: MAX_SPEND
        description: Maximum spend per subject
        data_tests:
          - not_null
  - name: FAN_ARTIST_DBT
    description: '{{ doc("FAN_ARTIST_DBT") }}'
    data_tests:
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
            - CUSTOM_LIST_ID
      - dbt_utils.expression_is_true:
          expression: "custom_list_id is not null"
          config:
            where: "global_participant_id is null"
      - dbt_utils.expression_is_true:
          expression: "global_participant_id is not null"
          config:
            where: "custom_list_id is null"
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        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
        description: Global participant ID from Orchard
      - name: CUSTOM_LIST_ID
        description: Custom list ID from CRM
  - name: FAN_ARTIST_MARKETING_CONSENT_DBT
    description: '{{ doc("FAN_ARTIST_MARKETING_CONSENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
            - CUSTOM_LIST_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
      - dbt_utils.expression_is_true:
          expression: "custom_list_id is not null"
          config:
            where: "global_participant_id is null"
      - dbt_utils.expression_is_true:
          expression: "global_participant_id is not null"
          config:
            where: "custom_list_id is null"
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        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
        description: Global participant ID from Orchard
      - name: CUSTOM_LIST_ID
        description: Custom list ID from CRM
      - name: EMAIL
        description: Boolean representing email campaign consent
        data_tests:
          - not_null
      - name: EMAIL_ELIGIBLE_DATE
        description: Earliest date when the fan became eligible for email marketing
  - name: FAN_MARKETING_CONSENT_DBT
    description: '{{ doc("FAN_MARKETING_CONSENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: RETARGETING
        description: Boolean representing retargeting campaign consent
        data_tests:
          - not_null
  - name: FAN_LOCATION_DBT
    description: '{{ doc("FAN_LOCATION_DBT") }}'
    data_tests:
      - dbt_utils.expression_is_true:
          expression: "LENGTH(COUNTRY_ISO2) = 2"
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - COUNTRY_ISO2
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: COUNTRY_ISO2
        description: ISO2 Country Code
        data_tests:
          - not_null
      - name: REGION
        description: Name of the region
      - name: CITY
        description: Name of the fan city
      - name: REGION_CODE
        description: Code representing city
      - name: CITY_ID
        description: ID representing city
      - name: LATITUDE
        description: Latitude in WGS84 system for city
      - name: LONGITUDE
        description: Longitude in WGS84 system for city
      - name: POSTAL_CODE
        description: Postal code identifier
      - name: COORDINATES_FROM_POSTAL_CODE
        description: Boolean indicating if coordinates are based on postal code
  - name: FAN_ARTIST_CUSTOM_LIST_LAST_EMAIL_EVENT_DBT
    description: '{{ doc("FAN_ARTIST_CUSTOM_LIST_LAST_EMAIL_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
            - CUSTOM_LIST_ID
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
      - dbt_utils.expression_is_true:
          expression: "custom_list_id is not null"
          config:
            where: "global_participant_id is null"
      - dbt_utils.expression_is_true:
          expression: "global_participant_id is not null"
          config:
            where: "custom_list_id is null"
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        description: Global participant ID from Orchard
      - name: CUSTOM_LIST_ID
        description: Custom list ID from CRM
      - name: LAST_EMAIL_EVENT_DATE
        description: Date representing when last email activity related event took place
        data_tests:
          - not_null
  - name: INT_FAN_SALESCLOUD_RETARGET_CONSENT
    description: '{{ doc("INT_FAN_SALESCLOUD_RETARGET_CONSENT") }}'
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
          - unique
      - name: FAN_ID_C
        description: CRM Fan ID
        data_tests:
          - not_null
      - name: RETARGETING_CONSENT
        description: Whether a given fan has granted an explicit or implicit retargeting consent
        data_tests:
          - not_null
  - name: FAN_ARTIST_TEXT_CONSENT_DBT
    description: '{{ doc("FAN_ARTIST_TEXT_CONSENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
            - CUSTOM_LIST_ID
#      - dbt_expectations.expect_table_row_count_to_be_between:
#          min_value: 1
      - dbt_utils.expression_is_true:
          expression: "custom_list_id is not null"
          config:
            where: "global_participant_id is null"
      - dbt_utils.expression_is_true:
          expression: "global_participant_id is not null"
          config:
            where: "custom_list_id is null"
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        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
        description: Global participant ID from Orchard
      - name: CUSTOM_LIST_ID
        description: Custom list ID from CRM
      - name: TEXT
        description: Boolean representing text campaign consent
        data_tests:
          - not_null
  - name: FAN_ARTIST_LAST_SMS_EVENT_DBT
    description: '{{ doc("FAN_ARTIST_LAST_SMS_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
#      - dbt_expectations.expect_table_row_count_to_be_between:
#          min_value: 1
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        description: Global participant ID from Orchard
      - name: LATEST_EVENT_DATE
        description: Date representing when last inbound sms activity related event took place
        data_tests:
          - not_null
