version: 2
models:
  - name: defi__fact_stake_pool_actions
    description: "{{ doc('fact_stake_pool_actions') }}"
    recent_date_filter: &recent_date_filter
      config:
        where: modified_timestamp >= current_date - 7
    tests:
      - reference_tx_missing:
          reference_tables:
            - 'silver__stake_pool_actions_lido'
            - 'silver__stake_pool_actions_generic'
            - 'silver__stake_pool_actions_marinade'
            - 'silver__stake_pool_actions_jito'
          id_column: 'tx_id'
    columns:
      - name: STAKE_POOL_NAME
        description: "{{ doc('stake_pool_name') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter 
      - name: BLOCK_TIMESTAMP
        description: "{{ doc('block_timestamp') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter 
      - name: BLOCK_ID
        description: "{{ doc('block_id') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter 
      - name: TX_ID
        description: "{{ doc('tx_id') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter 
      - name: INDEX
        description: "{{ doc('event_index') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter 
      - name: SUCCEEDED
        description: "{{ doc('tx_succeeded') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter 
      - name: ACTION
        description: "{{ doc('stake_pool_action') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter 
      - name: STAKE_POOL
        description: "{{ doc('stake_pool') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter 
      - name: ADDRESS
        description: "{{ doc('stake_pool_address') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter 
      - name: AMOUNT
        description: "{{ doc('stake_pool_amount') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null:
              config:
                where: >
                  modified_timestamp >= current_date - 7
                  AND succeeded
      - name: TOKEN
        description: "{{ doc('stake_pool_token') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter 
      - name: FACT_STAKE_POOL_ACTIONS_ID
        description: "{{ doc('pk') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
          - unique: *recent_date_filter    
      - name: INSERTED_TIMESTAMP
        description: "{{ doc('inserted_timestamp') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter   
      - name: MODIFIED_TIMESTAMP
        description: "{{ doc('modified_timestamp') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter 