version: 2
models:
  - name: silver__votes
    recent_date_filter: &recent_date_filter
      config:
        where: _inserted_timestamp >= current_date - 7
    tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - TX_ID
          where: block_timestamp::date > current_date - 7
    columns:
      - name: BLOCK_TIMESTAMP
        description: "{{ doc('block_timestamp') }}"
        tests:
          - not_null:
              where: block_id > 39824213 and _inserted_timestamp::date < current_date
      - name: BLOCK_ID
        description: "{{ doc('block_id') }}"
        tests:
          - not_null: *recent_date_filter
      - name: TX_ID
        description: "{{ doc('tx_id') }}"
        tests:
          - not_null: *recent_date_filter
      - name: RECENT_BLOCK_HASH
        description: Previous block's hash value
        tests:
          - not_null: *recent_date_filter
      - name: SIGNERS
        description: List of accounts that signed the transaction
      - name: FEE
        description: Transaction fee (in lamports)
        tests: 
          - null_threshold:
              threshold_percent: 0.99 # some older transactions have valid null fees
              where: block_timestamp::date > current_date - 30
      - name: SUCCEEDED
        description: "{{ doc('tx_succeeded') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: ACCOUNT_KEYS
        description: List of accounts that are referenced by pre/post sol/token balances objects
        tests: 
          - not_null: *recent_date_filter
      - name: VOTE_ACCOUNT
        description: Account belonging to the voting delegator
        tests: 
          - null_threshold:
              threshold_percent: 0.9999 # some vote program transactions don't have vote accounts or unknown which account is vote account
              where: block_timestamp::date > current_date - 30
      - name: VOTE_AUTHORITY
        description: Authority for the voting delegator
        tests: 
          - not_null: 
              enabled: false # Vote authority not always available
      - name: VOTE_HASH
        description: Unique hash representing this set of votes(?)
      - name: VOTE_SLOTS
        description: Slots being voted on
      - name: _PARTITION_ID
        description: Value representing a single pipeline execution batch
      - name: _INSERTED_TIMESTAMP
        description: "{{ doc('_inserted_timestamp') }}"
        tests: 
          - not_null
