version: 2
models:
  - name: GLOBAL_FAN_SEGMENT_DBT
    description: '{{ doc("GLOBAL_FAN_SEGMENT_DBT") }}'
    data_tests:
#      - dbt_utils.expression_is_true:
#          expression: "TOTAL_POINTS > 0"
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: TOTAL_POINTS
        description: Total points fan scored
        data_tests:
          - not_null
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist
        data_tests:
          - not_null
          - relationships:
              to: ref('COLLECTION_DBT')
              field: GLOBAL_PARTICIPANT_ID
      - name: SEGMENT_NAME
        description: Name of the segment where fan was assigned based on scoring
        data_tests:
          - not_null
          - accepted_values:
              values: [ 'NEW_FANS', 'FANS_TO_WIN_BACK', 'SECONDARY_FANS','CASUAL_FANS','ENGAGED_FANS', 'SUPER_FANS', 'UNSEGMENTED_FANS' ]
      - name: SEGMENT
        description: Numerical representation of final segment
        data_tests:
          - not_null
          - accepted_values:
              values: [-2, -1, 0, 1, 2, 3, 4]
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
      - name: CREATED_AT
        description: Timestamp when segments were calculated
