version: 2
models:
  - name: silver__swaps_intermediate_jupiterv4_2
    tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - TX_ID
            - INDEX
            - INNER_INDEX
            - SWAP_INDEX
          where: block_timestamp::date > current_date - 30
      - compare_model_subset:
          name: silver__swaps_intermediate_jupiterv4_2_business_logic_test
          compare_model: ref('testing__swaps_intermediate_jupiterv4_2')
          compare_columns: 
            - tx_id
            - swapper
            - from_mint
            - round(from_amount,2)
            - to_mint
            - round(to_amount,2)
            - swap_index
          model_condition: "where tx_id in ('3tcxJfm29b3yhTuGBM6rZTevBUQ2GPEd4Y1o856epRbuBGYdm7L4tFNb3JdL8tPZxWcanuByVNdHeQMpdi53arzv',
          '4ZjTuZyq3BTMVaciLQNwWFA2yHydBNWHC8nYSP33TxEedKgZok7m62cpMkQrBBnCC8PcMfSpzery4HDG3BxmdYGC',
          '4oFr1wz6jKBjqJb1FCv6ZypUdF2vEXuvPEHK1gABrvvCWHP5mDyfLTMRrXzHEDhHk1Z983R9sKkcFGcgfTHsjvBR',
          '5Wj1T8eKwAEnbRUrrv6T86r9SrboeDJ4mQNnGZJx1gHhBaujfzgntLh6yjy9TfuFDDdVVNYutWdVoW8byfAJzLAv',
          '5Z8eDs2uQ4EHvMn6s94EaezkY5YHKRes5gufaCcYu9P65zxnUYuXcwyu766XH85j5dSjzh8BspVPrs3mg74J3hKF',
          '62wto8Nr1fXQehypLxVy6n4mp6Pdb91hog2yTniAwg2Q6onWJh434gVqrHtbYs6oiDkBysqDMdVSB2q1z6V8z6D6',
          '5mXRCiDTYcoBjhmCm32r9r5TSeRtyYASAJkWPrNNUwDaKzhF6ye2VfKdNfoevuxAjkfp3Kojg1Trix1sTnb4jW41',
          '5eP2sF6tX9sBj7rLb97dK5AWFx8EHoVeuoxPDjvZojtQEznBRoGFq2prQzQJE93Xe3izRCB1nwhnRRvRoBEibLDW',
          '59GfwKse9EUygc69RaBFmPfeabaJFegEzXpQ55vmJmAfS4wJaJ91pVnm6r3RWaHqq2kF7Mh3Y9hCWp2wFrBqz3dk',
          '4Kvrre2S5gPffgSfQhCk8tMUAT8BQD8AiaZooms5hKTLEK7yCg9cs28LrXiKoGn3bZnUJj223f8HHoCnMVVe9BxM',
          '5vCvutCV5YwBu5D8gqXRH6nbvUvbTnG7ATVBKYBwaUDYiSu2gjPF3NtSLoiFCuoCopHdiRjPM3fQCXTLmz13eQjS',
          '54QLdpNX4CeBfDK2gdcxtsx6bdKFoPokdhqGy1BqVkFq56NeZ4X6ozeGLNknMWNA2deX19s64E8Xvy9C9u4A8Jzu')"
    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('event_index') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: INNER_INDEX
        description: "{{ doc('inner_index') }}"
      - name: SWAP_INDEX
        description: "{{ doc('swaps_swap_index') }}"
        tests: 
          - not_null: *recent_date_filter
      - 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: NOT truncated_log AND _inserted_timestamp >= current_date - 7
      - name: FROM_MINT
        description:  "{{ doc('swaps_from_mint') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: FROM_AMOUNT
        description:  "{{ doc('swaps_from_amt') }}"
        tests: 
          - not_null:
              where: NOT truncated_log AND _inserted_timestamp >= current_date - 7
      - name: TO_MINT
        description:  "{{ doc('swaps_to_mint') }}"
        tests: 
          - not_null:
              where: NOT truncated_log AND _inserted_timestamp >= current_date - 7
      - name: TO_AMOUNT
        description:  "{{ doc('swaps_to_amt') }}"
        tests: 
          - not_null:
              where: NOT truncated_log AND _inserted_timestamp >= current_date - 7
      - name: TRUNCATED_LOG
        description:  "Whether logs are truncated"
      - name: _INSERTED_TIMESTAMP
        description: "{{ doc('_inserted_timestamp') }}"
        tests: 
          - not_null
      - name: SWAPS_INTERMEDIATE_JUPITERV4_ID
        description: '{{ doc("pk") }}'   
        tests: 
          - unique: *recent_date_filter
      - name: INSERTED_TIMESTAMP
        description: '{{ doc("inserted_timestamp") }}'   
        tests: 
          - not_null: *recent_date_filter
      - name: MODIFIED_TIMESTAMP
        description: '{{ doc("modified_timestamp") }}' 
        tests: 
          - not_null: *recent_date_filter
      - name: _INVOCATION_ID
        description: '{{ doc("_invocation_id") }}' 
        tests: 
          - not_null: 
              name: test_silver__not_null_swaps_intermediate_jupiterv4_2__invocation_id
              <<: *recent_date_filter
