version: 2
models:
  - name: gov__fact_vote_accounts
    description: "{{ doc('fact_vote_accounts') }}"
    recent_date_filter: &recent_date_filter
      config:
        where: modified_timestamp >= current_date - 7
    tests:
      - reference_tx_missing:
          reference_tables:
            - 'silver__snapshot_vote_accounts'
          id_column: 'vote_pubkey'
    columns:
      - name: epoch
        description: "{{ doc('epoch') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: authorized_voter
        description: "{{ doc('authorized_voter') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null:
              where: (modified_timestamp >= current_date - 7) and authorized_withdrawer <> '11111111111111111111111111111111'
      - name: last_epoch_active
        description: "{{ doc('last_epoch_active') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: authorized_withdrawer
        description: "{{ doc('authorized_withdrawer') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: commission
        description: "{{ doc('commission') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: epoch_credits
        description: "{{ doc('epoch_credits') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: last_timestamp_slot
        description: "{{ doc('last_timestamp_slot') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: last_timestamp
        description: "{{ doc('last_timestamp') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: node_pubkey
        description: "{{ doc('node_pubkey') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: prior_voters
        description: "{{ doc('prior_voters') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: root_slot
        description: "{{ doc('root_slot') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: votes
        description: "{{ doc('votes') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: account_sol
        description: "{{ doc('account_sol') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: owner
        description: "{{ doc('vote_account_owner') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: rent_epoch
        description: "{{ doc('rent_epoch') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: vote_pubkey
        description: "{{ doc('vote_pubkey') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: FACT_VOTE_ACCOUNTS_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