version: 2
models:
  - name: EVENT_DBT
    description: TBA
    columns:
      - name: ID
        data_tests:
          - not_null
          - unique
      - name: SOURCE
        data_tests:
          - not_null
          - accepted_values:
              values:
                - 'sme_crm'
                - 'ae'
                - 'sme_marketing_cloud'
                - 'sme_shopify'
                - 'shopify'
                - 'songwhip'
                - 'fileupload_crm'
                - 'sendgrid'
                - 'bandsintown'
                - 'twilio'
      - name: SOURCE_TYPE
        data_tests:
          - not_null
          - accepted_values:
              values:
                - 'campaign'
                - 'newsletter'
                - 'activity_first'
                - 'activity_last'
                - 'email_open'
                - 'email_click'
                - 'ticket_purchase'
                - 'order'
                - 'order_line'
                - 'presave'
                - 'ticket_click'
                - 'artist_optin'
                - 'sme_optin'
                - 'artist_tracking'
                - 'rsvp'
                - 'sms_optin'
                - 'sms_message'
                - 'page_unlock'
      - name: FAN_ID
        data_tests:
          - not_null
          - dbt_expectations.expect_column_value_lengths_to_equal:
              value: 64
      - name: HAPPENED_AT
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: "< CAST(CONVERT_TIMEZONE('UTC', CURRENT_TIMESTAMP) AS TIMESTAMP_NTZ)"
      - name: CREATED_AT
        data_tests:
          - not_null
  - name: COLLECTION_DBT
    data_tests:
      - dbt_utils.expression_is_true:
          expression: "global_participant_id is not null"
          config:
            where: "custom_list_id is null"
      - dbt_utils.expression_is_true:
          expression: "custom_list_id is not null"
          config:
            where: "global_participant_id is null"
    description: TBA
    columns:
      - name: ID
        data_tests:
          - not_null
          - unique
      - name: SOURCE
        data_tests:
          - not_null
          - accepted_values:
              values:
                - 'sme_crm'
                - 'ae'
                - 'sme_marketing_cloud'
                - 'sme_shopify'
                - 'shopify'
                - 'songwhip'
                - 'fileupload_crm'
                - 'sendgrid'
                - 'bandsintown'
                - 'twilio'
      - name: SOURCE_TYPE
        data_tests:
          - not_null
          - accepted_values:
              values:
                - 'campaign'
                - 'newsletter'
                - 'activity_first'
                - 'activity_last'
                - 'email_open'
                - 'email_click'
                - 'ticket_purchase'
                - 'order'
                - 'order_line'
                - 'presave'
                - 'ticket_click'
                - 'artist_optin'
                - 'sme_optin'
                - 'artist_tracking'
                - 'rsvp'
                - 'sms_optin'
                - 'sms_message'
                - 'page_unlock'
      - name: VENDOR_ID
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '> 0'
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '>= 0'
      - name: GLOBAL_PARTICIPANT_ID
      - name: CUSTOM_LIST_ID
      - name: CREATED_AT
        data_tests:
          - not_null
      - name: UPDATED_AT
        data_tests:
          - not_null
  - name: EVENT_COLLECTION_DBT
    description: TBA
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - EVENT_ID
            - COLLECTION_ID
    columns:
      - name: EVENT_ID
        data_tests:
          - not_null
      - name: COLLECTION_ID
        data_tests:
          - not_null
  - name: STG_SME_EMAIL_CLICK_EVENT_DBT
    description: '{{ doc("STG_SME_EMAIL_CLICK_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: CRM_FAN_ID
        data_tests:
          - not_null
  - name: STG_SME_EMAIL_OPEN_EVENT_DBT
    description: '{{ doc("STG_SME_EMAIL_OPEN_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: CRM_FAN_ID
        data_tests:
          - not_null
  - name: STG_SENDGRID_EMAIL_CLICK_EVENT_DBT
    description: '{{ doc("STG_SENDGRID_EMAIL_CLICK_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: CRM_FAN_ID
  - name: STG_SENDGRID_EMAIL_OPEN_EVENT_DBT
    description: '{{ doc("STG_SENDGRID_EMAIL_OPEN_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: CRM_FAN_ID
  - name: STG_SENDGRID_CUSTOM_LIST_EMAIL_CLICK_EVENT_DBT
    description: '{{ doc("STG_SENDGRID_CUSTOM_LIST_EMAIL_CLICK_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: CRM_FAN_ID
  - name: STG_SENDGRID_CUSTOM_LIST_EMAIL_OPEN_EVENT_DBT
    description: '{{ doc("STG_SENDGRID_CUSTOM_LIST_EMAIL_OPEN_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: CRM_FAN_ID
  - name: STG_SME_SHOPIFY_ORDER_EVENT_DBT
    description: '{{ doc("STG_SME_SHOPIFY_ORDER_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - KEY
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: SOURCE
      - name: SOURCE_TYPE
      - name: KEY
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
      - name: CRM_FAN_ID
  - name: STG_SHOPIFY_ORDER_LINE_EVENT_DBT
    description: '{{ doc("STG_SHOPIFY_ORDER_LINE_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - KEY
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: SOURCE
      - name: SOURCE_TYPE
      - name: KEY
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
  - name: STG_SME_CRM_TICKET_EVENT_DBT
    description: '{{ doc("STG_SME_CRM_TICKET_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - KEY
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: SOURCE
      - name: SOURCE_TYPE
      - name: KEY
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: CRM_FAN_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
  - name: STG_SME_CRM_NEWSLETTER_EVENT_DBT
    description: '{{ doc("STG_SME_CRM_NEWSLETTER_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: CRM_FAN_ID
        data_tests:
          - not_null
  - name: STG_SME_CRM_CAMPAIGN_EVENT_DBT
    description: '{{ doc("STG_SME_CRM_CAMPAIGN_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: CRM_FAN_ID
        data_tests:
          - not_null
  - name: INT_CRM_FAN_DBT
    description: '{{ doc("INT_CRM_FAN_DBT") }}'
    columns:
      - name: CRM_FAN_ID
        description: Id representing fan from CRM
        data_tests:
          - not_null
          - unique
      - name: CRM_FAN_EMAIL
        description: Fan email from CRM
      - name: CRM_FAN_GENDER
        description: Fan gender from CRM
      - name: CRM_FAN_BIRTHDATE
        description: Fan date of birth from CRM
      - name: CRM_FAN_BIRTHDAY_MM_DD
        description: >
          Fan birthday in MM/DD format from CRM. Values that don't conform to
          zero-padded MM/DD (month 01-12, day 01-31) are coerced to NULL.
        data_tests:
          - dbt_utils.expression_is_true:
              expression: "RLIKE '^(0[1-9]|1[0-2])/(0[1-9]|[12][0-9]|3[01])$'"
              config:
                where: "CRM_FAN_BIRTHDAY_MM_DD IS NOT NULL"
      - name: CRM_FAN_DSP
        description: Fan related DSP values from CRM
      - name: CRM_FAN_FIRST_NAME
        description: Fan first name from CRM
      - name: CRM_FAN_LAST_NAME
        description: Fan last name from CRM
      - name: CRM_FAN_MOBILE_PHONE
        description: Fan mobile number from CRM
      - name: CRM_CUSTOMER_ID
        description: ID referencing Shopify customer id- from CRM
      - name: CRM_LAST_MODIFIED_DATE
        description: Date when fan related data was last modified in CRM
      - name: CRM_FAN_COUNTRY
        description: Fan related country from CRM
      - name: CRM_FAN_CITY
        description: Fan related city from CRM
      - name: CRM_FAN_REGION
        description: Fan related region from CRM
  - name: INT_EVENT_COLLECTION_JOIN
    description: '{{ doc("INT_EVENT_COLLECTION_JOIN") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
            - CUSTOM_LIST_ID
            - EVENT_ID
      - dbt_utils.expression_is_true:
          expression: "global_participant_id is not null"
          config:
            where: "custom_list_id is null"
      - dbt_utils.expression_is_true:
          expression: "custom_list_id is not null"
          config:
            where: "global_participant_id is null"
    columns:
      - name: SOURCE
        description: Where collection came from
      - name: SOURCE_TYPE
        description: What type is the collection source
      - name: VENDOR_ID
        description: ID representing vendor from Orchard
      - name: SUBACCOUNT_ID
        description: ID representing subaccount from Orchard
      - name: GLOBAL_PARTICIPANT_ID
        description: ID representing global participant from Orchard
      - name: FAN_ID
        description: ID representing fan in the Fansifter database
      - name: EVENT_ID
        description: ID representing events in the Fansifter event table
        data_tests:
          - not_null
      - name: KEY
        description: Column referencing key columns in source
      - name: CREATED_AT
        description: Date when event was created in the Fansifter event table
      - name: HAPPENED_AT
        description: Date when event was created in the source system
  - name: INT_PRIMARY_FANS_DBT
    description: '{{ doc("INT_PRIMARY_FANS_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
            - FAN_ID
    columns:
      - name: VENDOR_ID
        description: ID representing vendor from Orchard
      - name: SUBACCOUNT_ID
        description: ID representing subaccount from Orchard
      - name: GLOBAL_PARTICIPANT_ID
        description: ID representing global participant from Orchard
      - name: FAN_ID
        description: ID representing fan in the Fansifter database
  - name: STG_HEAVY_ROTATION_DBT
    description: '{{ doc("STG_HEAVY_ROTATION_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - BRAND_ID
    columns:
      - name: ID
        description: Id representing one activity collected from AE
        data_tests:
          - not_null
      - name: MEMBER_ID
        description: Id representing fan in AE
        data_tests:
          - not_null
      - name: BRAND_ID
        description: Id representing brand in AE
        data_tests:
          - not_null
      - name: LOAD_TIMESTAMP
        description: Timestamp of data load
        data_tests:
          - not_null
      - name: COMPLETE_DATE
        description: Timestamp of AE activity
        data_tests:
          - not_null
  - name: GLOBAL_PARTICIPANT_CRM_ARTIST_DBT
    description: '{{ doc("GLOBAL_PARTICIPANT_CRM_ARTIST_DBT") }}'
    columns:
      - name: ID
        description: Global Participant ID
        data_tests:
          - not_null
          - unique
      - name: CRM_ARTIST_ID
        description: CRM Artist ID
        data_tests:
          - not_null
          - unique
  - name: GLOBAL_PARTICIPANT_ACCOUNT_DBT
    description: '{{ doc("GLOBAL_PARTICIPANT_ACCOUNT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
    columns:
      - name: ID
        description: Global Participant ID
        data_tests:
          - not_null
      - name: SPOTIFY_ID
        description: Spotify 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: BRAND_NAME
        description: Company Brand Name the Vendor belongs to
        data_tests:
          - not_null
      - name: REP_TYPE
        description: |
          For SME labels, this is a type of Rep relationship according to their roster provided to Fansifter.
          It's either MAIN (Rep Owner) or LOCAL (IRL Rep).
          NULL value means it's either a non-SME label, or a given SME label did not include this artist into their roster but has previously collected fan data for them.
  - name: SME_ACCOUNT_DBT
    description: '{{ doc("SME_ACCOUNT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - VENDOR_ID
            - SUBACCOUNT_ID
            - CRM_LABEL_ID
            - CRM_TERRITORY_ID
      - dbt_utils.expression_is_true:
          expression: "CRM_LABEL_ID IS NOT NULL OR CRM_TERRITORY_ID IS NOT NULL"
    columns:
      - name: VENDOR_ID
        description: Vendor ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        description: Subaccount ID
          - not_null
      - name: CRM_LABEL_ID
        description: |
          CRM Label ID. If it is null and CRM_TERRITORY_ID is not null,
          data is ingested from all labels on that territory.
      - name: CRM_TERRITORY_ID
        description: |
            CRM Territory ID. If it is null and CRM_LABEL_ID is not null,
            the data is ingested from all territories for this label.
      - name: AE_BUSINESS_UNIT_NAME
        description: AE Business Unit Name
      - name: AE_REPORT_LICENSOR
        description: AE Report Licensor (theorchard/sme)
      - name: AE_LABEL
        description: AE Report Licensor (theorchard/sme)
      - name: EMAIL_ACCOUNT_ID
        description: Salesforce Marketing Cloud Business Unit ID
      - name: EMAIL_NAME_PREFIX
        description: Prefix of email names to filter by
  - name: STG_SME_AE_ACTIVITY_EVENT_DBT
    description: '{{ doc("STG_SME_AE_ACTIVITY_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - SOURCE
            - SOURCE_TYPE
            - KEY
            - FAN_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: SOURCE
        data_tests:
          - not_null
      - name: SOURCE_TYPE
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
        data_tests:
          - not_null
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
      - name: CRM_FAN_ID
  - name: STG_SONGWHIP_PRESAVE_EVENT_DBT
    description: '{{ doc("STG_SONGWHIP_PRESAVE_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - SOURCE
            - SOURCE_TYPE
            - KEY
            - FAN_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: SOURCE
        data_tests:
          - not_null
      - name: SOURCE_TYPE
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
        data_tests:
          - not_null
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
      - name: CRM_FAN_ID
  - name: STG_SONGWHIP_AE_ACTIVITY_EVENT_DBT
    description: '{{ doc("STG_SONGWHIP_AE_ACTIVITY_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - SOURCE_TYPE
            - KEY
            - FAN_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: SOURCE
      - name: SOURCE_TYPE
        data_tests:
          - not_null
      - name: KEY
      - name: FAN_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
        data_tests:
          - not_null
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
      - name: CRM_FAN_ID
  - name: STG_EXTERNAL_EVENT_DBT
    description: '{{ doc("STG_EXTERNAL_EVENT_DBT") }}'
    columns:
      - name: ID
      - name: SOURCE
      - name: SOURCE_TYPE
      - name: KEY
      - name: FAN_ID
      - name: FAN_EMAIL
      - name: HAPPENED_AT
      - name: VENDOR_ID
      - name: SUBACCOUNT_ID
      - name: GLOBAL_PARTICIPANT_ID
      - name: CRM_FAN_ID
  - name: INT_EXTERNAL_EVENT_DBT
    description: '{{ doc("INT_EXTERNAL_EVENT_DBT") }}'
    columns:
      - name: ID
      - name: SOURCE
      - name: SOURCE_TYPE
      - name: KEY
      - name: FAN_ID
      - name: HAPPENED_AT
      - name: VENDOR_ID
      - name: SUBACCOUNT_ID
      - name: GLOBAL_PARTICIPANT_ID
      - name: CRM_FAN_ID
  - name: STG_SME_CRM_CUSTOM_LIST_EMAIL_CLICK_EVENT_DBT
    description: '{{ doc("STG_SME_CRM_CUSTOM_LIST_EMAIL_CLICK_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - CUSTOM_LIST_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: CRM_FAN_ID
        data_tests:
          - not_null
  - name: STG_SME_CRM_CUSTOM_LIST_EMAIL_OPEN_EVENT_DBT
    description: '{{ doc("STG_SME_CRM_CUSTOM_LIST_EMAIL_OPEN_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - CUSTOM_LIST_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: CRM_FAN_ID
        data_tests:
          - not_null
  - name: STG_SME_CRM_CUSTOM_LIST_TICKET_EVENT_DBT
    description: '{{ doc("STG_SME_CRM_CUSTOM_LIST_TICKET_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - KEY
            - VENDOR_ID
            - SUBACCOUNT_ID
            - CUSTOM_LIST_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: SOURCE
      - name: SOURCE_TYPE
      - name: KEY
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: CRM_FAN_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: CUSTOM_LIST_ID
        data_tests:
          - not_null
  - name: STG_SME_CRM_CUSTOM_LIST_NEWSLETTER_EVENT_DBT
    description: '{{ doc("STG_SME_CRM_CUSTOM_LIST_NEWSLETTER_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - CUSTOM_LIST_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: CRM_FAN_ID
        data_tests:
          - not_null
  - name: STG_SME_CRM_CUSTOM_LIST_CAMPAIGN_EVENT_DBT
    description: '{{ doc("STG_SME_CRM_CUSTOM_LIST_CAMPAIGN_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - CUSTOM_LIST_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: CRM_FAN_ID
        data_tests:
          - not_null
  - name: STG_FAN_EMAIL_DBT
    description: '{{ doc("STG_FAN_EMAIL_DBT") }}'
    config:
      materialized: table
      tags: ["python"]
      python_version: "3.11"
      packages:
        - "email-validator"
    columns:
      - name: FAN_ID
        data_tests:
          - not_null
          - unique
      - name: FAN_EMAIL
        data_tests:
          - not_null
      - name: FAN_EMAIL_DOMAIN
        data_tests:
          - not_null
  - name: STG_SME_FILEUPLOAD_CAMPAIGN_EVENT_DBT
    description: '{{ doc("STG_SME_FILEUPLOAD_CAMPAIGN_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
  - name: STG_CLEAN_FAN_MOBILE_PHONE_DBT
    description: '{{ doc("STG_CLEAN_FAN_MOBILE_PHONE_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - FAN_MOBILE
            - HAPPENED_AT
    config:
      materialized: table
      tags: ["python"]
      python_version: "3.11"
      packages:
        - "phonenumbers"
    columns:
      - name: FAN_ID
        data_tests:
          - not_null
      - name: FAN_MOBILE
        data_tests:
          - not_null
      - name: HAPPENED_AT
        data_tests:
          - not_null
  - name: STG_DEDUPLICATED_EXTERNAL_EVENTS_BY_FAN_ID_DBT
    description: '{{ doc("STG_DEDUPLICATED_EXTERNAL_EVENTS_BY_FAN_ID_DBT") }}'
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: SOURCE
        data_tests:
          - not_null
          - accepted_values:
              values:
                - 'sme_crm'
                - 'ae'
                - 'sme_marketing_cloud'
                - 'sme_shopify'
                - 'shopify'
                - 'songwhip'
                - 'fileupload_crm'
                - 'sendgrid'
                - 'bandsintown'
                - 'twilio'
      - name: SOURCE_TYPE
        data_tests:
          - not_null
          - accepted_values:
              values:
                - 'campaign'
                - 'newsletter'
                - 'activity_first'
                - 'activity_last'
                - 'email_open'
                - 'email_click'
                - 'ticket_purchase'
                - 'order'
                - 'order_line'
                - 'presave'
                - 'ticket_click'
                - 'artist_optin'
                - 'sme_optin'
                - 'artist_tracking'
                - 'rsvp'
                - 'sms_optin'
                - 'sms_message'
                - 'page_unlock'
      - name: FAN_ID
        data_tests:
          - not_null
          - dbt_expectations.expect_column_value_lengths_to_equal:
              value: 64
      - name: HAPPENED_AT
        data_tests:
          - not_null
  - name: STG_DEDUPLICATED_EXTERNAL_EVENTS_DBT
    description: '{{ doc("STG_DEDUPLICATED_EXTERNAL_EVENTS_DBT") }}'
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: SOURCE
        data_tests:
          - not_null
          - accepted_values:
              values:
                - 'sme_crm'
                - 'ae'
                - 'sme_marketing_cloud'
                - 'sme_shopify'
                - 'shopify'
                - 'songwhip'
                - 'fileupload_crm'
                - 'sendgrid'
                - 'bandsintown'
                - 'twilio'
      - name: SOURCE_TYPE
        data_tests:
          - not_null
          - accepted_values:
              values:
                - 'campaign'
                - 'newsletter'
                - 'activity_first'
                - 'activity_last'
                - 'email_open'
                - 'email_click'
                - 'ticket_purchase'
                - 'order'
                - 'order_line'
                - 'presave'
                - 'ticket_click'
                - 'artist_optin'
                - 'sme_optin'
                - 'artist_tracking'
                - 'rsvp'
                - 'sms_optin'
                - 'sms_message'
                - 'page_unlock'
      - name: FAN_ID
        data_tests:
          - not_null
          - dbt_expectations.expect_column_value_lengths_to_equal:
              value: 64
      - name: HAPPENED_AT
        data_tests:
          - not_null
  - name: STG_BIT_ARTIST_OPTIN_EVENT_DBT
    description: '{{ doc("STG_BIT_ARTIST_OPTIN_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: FAN_EMAIL
        data_tests:
          - not_null
  - name: STG_BIT_RSVP_EVENT_DBT
    description: '{{ doc("STG_BIT_RSVP_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: FAN_EMAIL
        data_tests:
          - not_null
  - name: STG_BIT_ARTIST_TRACKING_EVENT_DBT
    description: '{{ doc("STG_BIT_ARTIST_TRACKING_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: FAN_EMAIL
        data_tests:
          - not_null
  - name: STG_BIT_TICKET_CLICK_EVENT_DBT
    description: '{{ doc("STG_BIT_TICKET_CLICK_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: FAN_EMAIL
        data_tests:
          - not_null
  - name: STG_BIT_USER_PROFILE_DBT
    description: '{{ doc("STG_BIT_USER_PROFILE_DBT") }}'
    columns:
      - name: USER_ID
        data_tests:
          - not_null
          - unique
  - name: STG_SME_AE_ACTIVITY_FEED_DBT
    description: '{{ doc("STG_SME_AE_ACTIVITY_FEED_DBT") }}'
    data_tests:
      - dbt_expectations.expect_table_row_count_to_be_between:
          min_value: 1
  - name: INT_STG_AE_MEMBERS_DBT
    description: '{{ doc("INT_STG_AE_MEMBERS_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - MEMBER_ID
            - BUSINESS_UNIT_NAME
            - REPORT_LICENSOR
  - name: STG_TWILIO_SUBSCRIPTION_EVENT_DBT
    description: '{{ doc("STG_TWILIO_SUBSCRIPTION_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: FAN_MOBILE
        data_tests:
          - not_null
  - name: STG_TWILIO_FAN_MESSAGE_EVENT_DBT
    description: '{{ doc("STG_TWILIO_FAN_MESSAGE_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: FAN_MOBILE
        data_tests:
          - not_null
  - name: STG_SME_FILEUPLOAD_CUSTOM_LIST_CAMPAIGN_EVENT_DBT
    description: '{{ doc("STG_SME_FILEUPLOAD_CUSTOM_LIST_CAMPAIGN_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - KEY
            - VENDOR_ID
            - SUBACCOUNT_ID
            - CUSTOM_LIST_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: SOURCE
      - name: SOURCE_TYPE
      - name: KEY
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: CRM_FAN_ID
      - name: HAPPENED_AT
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: CUSTOM_LIST_ID
        data_tests:
          - not_null
  - name: STG_SONGWHIP_CUSTOM_PAGE_EVENT_DBT
    description: '{{ doc("STG_SONGWHIP_CUSTOM_PAGE_EVENT_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - SOURCE
            - SOURCE_TYPE
            - KEY
            - FAN_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: SOURCE
        data_tests:
          - not_null
      - name: SOURCE_TYPE
        data_tests:
          - not_null
      - name: KEY
        data_tests:
          - not_null
      - name: FAN_ID
        data_tests:
          - not_null
      - name: HAPPENED_AT
        data_tests:
          - not_null
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        data_tests:
          - not_null
      - name: CRM_FAN_ID