version: 2
models:
  - name: CRM_SUBLIST_ID_DBT
    description: '{{ doc("CRM_SUBLIST_ID_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - GLOBAL_PARTICIPANT_ID
            - CUSTOM_LIST_ID
            - VENDOR_ID
            - SUBACCOUNT_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: ID
        data_tests:
          - not_null
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
      - name: CUSTOM_LIST_ID
      - name: NAME
      - name: TERRITORY_NAME
      - name: LABEL_NAME
  - name: CRM_SUBLIST_FAN_DBT
    description: '{{ doc("CRM_SUBLIST_FAN_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - SUBLIST_ID
            - GLOBAL_PARTICIPANT_ID
            - CUSTOM_LIST_ID
            - VENDOR_ID
            - SUBACCOUNT_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
        data_tests:
          - not_null
      - name: SUBLIST_ID
        data_tests:
          - not_null
      - name: VENDOR_ID
        data_tests:
          - not_null
      - name: SUBACCOUNT_ID
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
      - name: CUSTOM_LIST_ID
