version: 2
models:
  - name: GLOBAL_STG_ALL_FANS_ARTISTS_DBT
    description: '{{ doc("GLOBAL_STG_ALL_FANS_ARTISTS_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)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: FIRST_EVENT_DATE
        description: Timestamp representing first event
      - name: LAST_EVENT_DATE
        description: Timestamp representing last event
  - name: GLOBAL_STG_SEGMENTATION_PREREQUISITES_DBT
    description: '{{ doc("GLOBAL_STG_SEGMENTATION_PREREQUISITES_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
        data_tests:
          - not_null
      - name: EMAIL_OPENS
        description: Nr of maximum email opens per fan and artist
      - name: EMAIL_CLICKS
        description: Nr of maximum email clicks per fan and artist
      - name: MAX_CAMPAIGNS
        description: Nr of maximum campaigns per fan and artist
      - name: NR_OF_FANS
        description: Nr of fans available for artist
      - name: MATCHING_FEATURES
        description: Nr of high quality features for artist
  - name: GLOBAL_STG_FANS_FOR_SEGMENTATION_DBT
    description: '{{ doc("GLOBAL_STG_FANS_FOR_SEGMENTATION_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
            - SOURCE_TYPE
            - PERIOD_NAME
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: SOURCE_TYPE
        description: Categorical value of source type
      - name: NR_OF_EVENTS
        description: Nr of events per fan and source type
      - name: PERIOD_NAME
        description: Period used for decay calculation
  - name: GLOBAL_STG_FANS_ENGINEERED_FEATURES_DBT
    description: '{{ doc("GLOBAL_STG_FANS_ENGINEERED_FEATURES_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
            - SOURCE_TYPE
            - PERIOD_NAME
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: SOURCE_TYPE
        description: Categorical value of engineered feature
      - name: NR_OF_EVENTS
        description: Nr of events per fan and engineered feature
      - name: PERIOD_NAME
        description: Period used for decay calculation
  - name: GLOBAL_STG_NEW_FANS_DBT
    description: '{{ doc("GLOBAL_STG_NEW_FANS_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)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: FIRST_EVENT_DATE
        description: Timestamp representing first event
      - name: ESTABLISHED_FAN
        description: Boolean representing if fan has been recently acquired or not
  - name: GLOBAL_STG_FANS_POINT_CALCULATION_DBT
    description: '{{ doc("GLOBAL_STG_FANS_POINT_CALCULATION_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
            - SOURCE_TYPE
            - PERIOD_NAME
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: SOURCE_TYPE
        description: Categorical value of engineered feature
      - name: PERIOD_NAME
        description: Period used for decay calculation
      - name: NR_OF_EVENTS
        description: Nr of events per fan
      - name: WORTH
        description: Numeric value each single instance of activity is worth of
      - name: CAP
        description: Maximum value fan can score per specific feature
      - name: DESCRIPTION
        description: Description of the feature being scored
      - name: FINAL_FEATURE_POINTS
        description: Total points fan scored for specific feature
      - name: PRIMARY_FEATURE
        description: Indicator if this is feature is primary or derived from primary
  - name: GLOBAL_STG_ARTIST_BIN_INTERVALS_DBT
    description: '{{ doc("GLOBAL_STG_ARTIST_BIN_INTERVALS_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - GLOBAL_PARTICIPANT_ID
            - SEGMENT
    columns:
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: MIN_TOTAL_POINTS
        description: Minimum points per vendor, subaccount and global participant
      - name: MAX_TOTAL_POINTS
        description: Maximum points per vendor, subaccount and global participant
      - name: MIN_LOG_TOTAL_POINTS
        description: Minimum points in logarithmic scale per vendor, 
          subaccount and global participant
      - name: MAX_LOG_TOTAL_POINTS
        description: Maximum points in logarithmic scale per vendor,
          subaccount and global participant
      - name: SEGMENT
        description: Numeric representation of segment
      - name: BIN_WIDTH
        description: Numeric value representing interval between bin start and end
      - name: BIN_START
        description: Numeric value where bin starts
      - name: BIN_END
        description: Numeric value where bin ends
      - name: LOG_BIN_WIDTH
        description: Numeric value representing interval between bin start and end 
          in logarithmic scale
      - name: LOG_BIN_START
        description: Numeric value where bin starts in logarithmic scale
      - name: LOG_BIN_END
        description: Numeric value  where bin ends in logarithmic scale
  - name: GLOBAL_STG_FANS_LOGARITHMIC_BINNING_DBT
    description: '{{ doc("GLOBAL_STG_FANS_LOGARITHMIC_BINNING_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)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: LOG_TOTAL_POINTS
        description: Total points in logarithmic scale scored by fan
      - name: TOTAL_POINTS
        description: Total points scored by fan
      - name: LOG_BIN_START
        description: Segment bin start in logarithmic scale
      - name: LOG_BIN_END
        description: Segment bin end in logarithmic scale
      - name: SEGMENT
        description: Numerical value of segment where fan was assigned
  - name: GLOBAL_STG_FANS_PLAYLIST_FOLLOW_FEATURE_DBT
    description: '{{ doc("GLOBAL_STG_FANS_PLAYLIST_FOLLOW_FEATURE_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
            - PERIOD_NAME
            - SOURCE_TYPE
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: SOURCE_TYPE
        description: Id representing AE feature
      - name: NR_OF_EVENTS
        description: Nr of AE 4830 or 4210 events per fan
      - name: PERIOD_NAME
        description: Period used for decay calculation
  - name: GLOBAL_STG_FANS_TOTAL_POINTS_DBT
    description: '{{ doc("GLOBAL_STG_FANS_TOTAL_POINTS_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)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: TOTAL_POINTS
        description: Total points fan scored based on all features
      - name: LOG_TOTAL_POINTS
        description: Total points fan scored based on all features
          in logarithmic scale
      - name: PRIMARY_TOTAL_EVENTS
        description: Excluding features derived
          from primary features
      - name: NON_DECAY_PRIMARY_TOTAL_POINTS
        description: Total points Excluding features derived from 
          primary features
      - name: NON_DECAY_LOG_PRIMARY_TOTAL_POINTS
        description: Total points fan scored based on all features
          in logarithmic scale but 
          excluding features derived from primary
  - name: GLOBAL_STG_SEGMENTED_FANS_DBT
    description: '{{ doc("GLOBAL_STG_SEGMENTED_FANS_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)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: BINNING_METHOD
        description: Describes what segmentation method was chosen
      - name: MATCHING
        description: Indicator showing what segmentation method was chosen
      - name: TOTAL_POINTS
        description: Total point fan scored
      - name: SEGMENT
        description: Numeric representation of the segment where fan belongs
  - name: GLOBAL_STG_AE_EVENTS_DBT
    description: '{{ doc("GLOBAL_STG_AE_EVENTS_DBT") }}'
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: SOURCE_TYPE
        description: Categorical value showing AE activity code
      - name: NR_OF_EVENTS
        description: Number of AE events per aggregation
      - name: PERIOD_NAME
        description: Period used for decay calculation
  - name: GLOBAL_STG_AE_FEATURES_FOR_PREREQUISITES_DBT
    description: '{{ doc("GLOBAL_STG_AE_FEATURES_FOR_PREREQUISITES_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - GLOBAL_PARTICIPANT_ID
    columns:
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
        data_tests:
          - not_null
      - name: ARRAY_AGG
        description: Array containing list of AE features
        data_tests:
          - not_null
  - name: GLOBAL_STG_FANS_SHOPIFY_FEATURES_DBT
    description: '{{ doc("GLOBAL_STG_FANS_SHOPIFY_FEATURES_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
            - SOURCE_TYPE
            - PERIOD_NAME
      - 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: Id representing artist(global participant)
        data_tests:
          - not_null
      - name: NR_OF_EVENTS
        description: Nr of events per fan and artist
        data_tests:
          - not_null
          - dbt_utils.expression_is_true:
              expression: '> 0'
      - name: SOURCE_TYPE
        description: Shopify related features
        data_tests:
          - not_null
          - accepted_values:
              values: [ 'TOTAL_ORDERS', 'ORDER_TOTAL' ]
      - name: PERIOD_NAME
        description: Period used for decay calculation

  - name: GLOBAL_STG_POTENTIAL_WINBACK_INDICATOR_DBT
    description: '{{ doc("GLOBAL_STG_POTENTIAL_WINBACK_INDICATOR_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: Id representing artist(global participant)
        data_tests:
          - not_null
      - name: TOTAL_EVENTS
        description: Nr of total events per fan and artist
        data_tests:
          - not_null
      - name: TOTAL_POINTS
        description: Nr of total points per fan and artist using decay factor
        data_tests:
          - not_null
      - name: LOG_TOTAL_POINTS
        description: Nr of total logarithmic points per fan and artist using decay factor
        data_tests:
          - not_null
      - name: NON_DECAY_TOTAL_POINTS
        description: Nr of total points per fan and artist without decay factor
        data_tests:
          - not_null
      - name: NON_DECAY_LOG_TOTAL_POINTS
        description: Nr of total logarithmic points per fan and artist without decay factor
        data_tests:
          - not_null
      - name: LAST_EVENT_DATE
        description: Latest event date for fan
        data_tests:
          - not_null
      - name: ONETIME_WINBACK_FAN
        description: Indicator if this is potential, win back or other type of fan
        data_tests:
          - not_null
          - accepted_values:
              values: [ 0, 1, 999 ]
      - name: PRIMARY_TOTAL_EVENTS
        description: Excluding features derived
          from primary features
      - name: NON_DECAY_PRIMARY_TOTAL_POINTS
        description: Total points Excluding features derived from 
          primary features
      - name: NON_DECAY_LOG_PRIMARY_TOTAL_POINTS
        description: Total points fan scored based on all features
          in logarithmic scale but 
          excluding features derived from primary
  - name: GLOBAL_STG_UPDATED_ARTIST_BIN_INTERVALS_DBT
    description: '{{ doc("GLOBAL_STG_UPDATED_ARTIST_BIN_INTERVALS_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - GLOBAL_PARTICIPANT_ID
            - SEGMENT
    columns:
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: MIN_TOTAL_POINTS
        description: Minimum points per vendor, subaccount and global participant
      - name: MAX_TOTAL_POINTS
        description: Maximum points per vendor, subaccount and global participant
      - name: MIN_LOG_TOTAL_POINTS
        description: Minimum points in logarithmic scale per global participant
      - name: MAX_LOG_TOTAL_POINTS
        description: Maximum points in logarithmic scale per global participant
      - name: SEGMENT
        description: Numeric representation of segment
      - name: BIN_WIDTH
        description: Numeric value representing interval between bin start and end
      - name: BIN_START
        description: Numeric value where bin starts
      - name: BIN_END
        description: Numeric value where bin ends
      - name: LOG_BIN_WIDTH
        description: Numeric value representing interval between bin start and end 
          in logarithmic scale
      - name: LOG_BIN_START
        description: Numeric value where bin starts in logarithmic scale
      - name: LOG_BIN_END
        description: Numeric value  where bin ends in logarithmic scale
  - name: GLOBAL_STG_SECONDARY_FANS_DBT
    description: '{{ doc("GLOBAL_STG_SECONDARY_FANS_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)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: BINNING_METHOD
        description: Describes what segmentation method was chosen
      - name: MATCHING
        description: Indicator showing what segmentation method was chosen
      - name: TOTAL_POINTS
        description: Total point fan scored
      - name: SEGMENT
        description: Numeric representation of the segment where fan belongs
  - name: GLOBAL_STG_FAN_POINT_OUTLIERS_DBT
    description: '{{ doc("GLOBAL_STG_FAN_POINT_OUTLIERS_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)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: TOTAL_POINTS
        description: Nr of total points per fan and artist using decay factor
  - name: GLOBAL_STG_SUPERFANS_FROM_OUTLIERS_DBT
    description: '{{ doc("GLOBAL_STG_SUPERFANS_FROM_OUTLIERS_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)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: TOTAL_EVENTS
        description: Nr of total events per fan and artist
      - name: TOTAL_POINTS
        description: Nr of total points per fan and artist using decay factor
      - name: LOG_TOTAL_POINTS
        description: Maximum points in logarithmic scale per vendor,
          subaccount and global participant
      - name: NON_DECAY_TOTAL_POINTS
        description: Nr of total points per fan and artist without decay factor
      - name: NON_DECAY_LOG_TOTAL_POINTS
        description: Nr of total logarithmic points per fan and artist without decay factor
      - name: LAST_EVENT_DATE
        description: Latest event date for fan
      - name: PRIMARY_TOTAL_EVENTS
        description: Excluding features derived
          from primary features
      - name: NON_DECAY_PRIMARY_TOTAL_POINTS
        description: Total points Excluding features derived from 
          primary features
      - name: NON_DECAY_LOG_PRIMARY_TOTAL_POINTS
        description: Total points fan scored based on all features
          in logarithmic scale but 
          excluding features derived from primary
  - name: GLOBAL_STG_FANS_WITHOUT_PROFILING_CONSENT_DBT
    description: '{{ doc("GLOBAL_STG_FANS_WITHOUT_PROFILING_CONSENT_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)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
  - name: GLOBAL_STG_FANS_BIT_ENGINEERED_FEATURES_DBT
    description: '{{ doc("GLOBAL_STG_FANS_BIT_ENGINEERED_FEATURES_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
            - SOURCE_TYPE
            - PERIOD_NAME
    columns:
      - name: FAN_ID
        description: Id representing fan (SHA256 of a lowercase fan email)
      - name: GLOBAL_PARTICIPANT_ID
        description: Id representing artist(global participant)
      - name: SOURCE_TYPE
        description: Categorical value of engineered feature
      - name: NR_OF_EVENTS
        description: Nr of events per fan and engineered feature
      - name: PERIOD_NAME
        description: Period used for decay calculation
