version: 2

sources:
  - name: gdelt
    description: "Raw GDELT data ingested by Dagster pipeline"
    freshness:
      warn_after: {count: 1, period: hour}
      error_after: {count: 3, period: hour}
    loaded_at_field: DATE
    tables:
      - name: events_dagster
        description: "Raw events from GDELT API"
      - name: gkg_emotions
        description: "Raw GKG emotion data from GDELT (rolling 24h articles)"
        columns:
          - name: GKG_ID
            description: "Unique GKG record identifier"
            tests:
              - unique
              - not_null
          - name: DATE
            description: "Record date in YYYYMMDD format"
            tests:
              - not_null
          - name: SOURCE
            description: "Source publication or outlet"
          - name: PERSONS
            description: "Persons mentioned in the article"
          - name: ORGS
            description: "Organizations mentioned in the article"
          - name: TOP_THEMES
            description: "Top GDELT themes extracted from the article"
          - name: AVG_TONE
            description: "Average tone score of the article"
          - name: POSITIVE_SCORE
            description: "Positive sentiment score"
          - name: NEGATIVE_SCORE
            description: "Negative sentiment score"
          - name: EMOTION_FEAR
            description: "Fear emotion score"
          - name: EMOTION_ANGER
            description: "Anger emotion score"
          - name: EMOTION_SADNESS
            description: "Sadness emotion score"
          - name: EMOTION_JOY
            description: "Joy emotion score"
          - name: EMOTION_DISGUST
            description: "Disgust emotion score"
          - name: EMOTION_SURPRISE
            description: "Surprise emotion score"
          - name: EMOTION_TRUST
            description: "Trust emotion score"
          - name: EMOTION_ANTICIPATION
            description: "Anticipation emotion score"
          - name: EMOTION_ANXIETY
            description: "Anxiety emotion score"
          - name: EMOTION_HOSTILITY
            description: "Hostility emotion score"
          - name: EMOTION_DEPRESSION
            description: "Depression emotion score"

models:
  - name: stg_events
    description: "Cleaned and standardized GDELT events"
    columns:
      - name: event_id
        description: "Unique event identifier"
        tests:
          - unique
          - not_null
      - name: event_date_raw
        description: "Raw date string (YYYYMMDD)"
        tests:
          - not_null
      - name: actor_name
        description: "Name of primary actor"
      - name: actor_country_code
        description: "3-letter ISO country code"
      - name: goldstein_scale
        description: "Event impact score (-10.0 to +10.0, FLOAT64)"
      - name: sentiment_category
        description: "Derived sentiment classification"
        tests:
          - accepted_values:
              values: ['Very Negative', 'Negative', 'Neutral', 'Positive', 'Very Positive']

  - name: stg_gkg_emotions
    description: "Cleaned GKG emotion records with derived sentiment and dominant emotion"
    columns:
      - name: gkg_id
        description: "Unique GKG record identifier"
        tests:
          - unique
          - not_null
      - name: date_str
        description: "Record date string (YYYYMMDDHHMMSS)"
        tests:
          - not_null
      - name: sentiment_category
        description: "Tone bucketed into negative / neutral / positive"
        tests:
          - accepted_values:
              values: ["negative", "neutral", "positive"]
      - name: dominant_emotion
        description: "Strongest Plutchik emotion for the article"
        tests:
          - accepted_values:
              values: ["fear", "anger", "sadness", "joy", "disgust", "surprise", "trust", "anticipation"]
