version: 2
models:
  - name: silver__swaps_intermediate_meteora
    tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - TX_ID
            - SWAP_INDEX
            - PROGRAM_ID
          where: block_timestamp::date > current_date - 30
      - compare_model_subset:
          name: silver__swaps_intermediate_meteora_business_logic_test
          compare_model: ref('testing__swaps_intermediate_meteora')
          compare_columns: 
            - tx_id
            - swapper
            - round(from_amt,8)
            - from_mint
            - round(to_amt,8)
            - to_mint
            - swap_index
          model_condition: "where tx_id in ('3DjUBQE4GwTMSFLGMi69TGMiBoNE8FfnryR8BCEmovGVmMz9Jfh9dG3ikLAPuQPWpv12ypS4nYx1Esc4TYUw3s44',
          '3RCs1zgEKNemq1syYM3ZZKHkckZgBbkgtKVq41W7j2yh5Ce4pVgHLU6QSiZX3nrijZ4S2yhYDb3K61seLR4c9FYu',
          'iBuwG5mU4LKMrN6iNVzGZSC7vXqvAfRQ98YJeKXPoDbM2oi7dvV8ZMnwgv55Db6JT4iokQ6JbVpN7jHnKkFtJqC',
          'NfvsjHzJx5s5JWDK7pJaWUv7hXJGdWUYwqaoRVLxQ2d5q3Jyrs2uft9FUyeNFVyxVSVZFPdsTv45dpgdog9RyzQ',
          '2eV5PUm4WL7X9T1X4nSbBmAGDLTx9pUiygK34ngMSyR9QwQUS8ZpnzGKTCbuJHeVGYNHjHBGtPh4fLYxkBLGVJeB',
          '35QkSCVWRNFaqFM8DZrDWKWsBdDTrHVMmskd3H9D3pcQstdYsWqZiXVhMpkaCFrBQTi8XZaWgNZaWnQZzwPpZ1dv',
          '2CkwiLBE82MALvqW4uHscPLbEdAqgVXhSPsmoeVPq6wzS9iTv1wDfwsE7SBqoR6j7L2KFyi2NMwAy5Yq5a45RuVy',
          '64PW2o1TjxU3kJXAWsAZrL6wJAhKeAY2esJNbjp9UfBb4q4mZMF9KdXXqv3DjkAiNZUacitwzU5v8rCCb3zkdvmp',
          '42a7GeWqCVi8p3e5EGqKh6pcYnuqK4c6Kjg9ZmiN7SKe1aFhtvUDQJrPiMinTwvKPeAcTVVYjXE4TH33mMH52yD5',
          '5KboaM89D79KwHwmRaoaSA7wD3xduMpdqVnWWxkEYvi4b16dTKBQBtGQYoQ1PgStD66mF95vi7FGNrcfmW3EGTpB')"  
    recent_date_filter: &recent_date_filter
      config:
        where: _inserted_timestamp >= current_date - 7
    columns:
      - name: BLOCK_TIMESTAMP
        description: "{{ doc('block_timestamp') }}"
        tests:
          - not_null: *recent_date_filter
          - dbt_expectations.expect_row_values_to_have_recent_data:
              datepart: day
              interval: 2
      - 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: INDEX
        description: "{{ doc('index') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: INNER_INDEX
        description: "{{ doc('inner_index') }}"
      - name: SUCCEEDED
        description: "{{ doc('tx_succeeded') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: PROGRAM_ID
        description: "{{ doc('program_id') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: SWAPPER
        description: "{{ doc('swaps_swapper') }}"
        tests: 
          - not_null:
              where: succeeded = TRUE AND _inserted_timestamp >= current_date - 7
      - name: FROM_AMT
        description:  "{{ doc('swaps_from_amt') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: FROM_MINT
        description:  "{{ doc('swaps_from_mint') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: TO_AMT
        description:  "{{ doc('swaps_to_amt') }}"
      - name: TO_MINT
        description:  "{{ doc('swaps_to_mint') }}"
      - name: SWAP_INDEX
        description: "{{ doc('swaps_swap_index') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: _INSERTED_TIMESTAMP
        description: "{{ doc('_inserted_timestamp') }}"
        tests: 
          - not_null