version: 2
models:
  - name: silver__decoded_logs
    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: 1
      - 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
          - dbt_utils.relationships_where:
              name: dbt_utils_relationships_where_silver__decoded_logs_swaps_pumpfun_tx_id
              to: ref('silver__swaps_pumpfun')
              field: tx_id
              from_condition: >
                program_id = '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P'
                AND event_type = 'TradeEvent'
                AND succeeded
                and _inserted_timestamp between current_date - 7 and current_timestamp() - INTERVAL '4 HOUR'
              to_condition: "_inserted_timestamp >= current_date - 7"
      - name: INDEX
        description: "{{ doc('event_index') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: INNER_INDEX
        description: "{{ doc('inner_index') }}"
      - name: LOG_INDEX
        description: "{{ doc('log_index') }}"
      - name: SIGNERS
        description: "{{ doc('signers') }}"
        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: DECODED_LOG
        description: A log that describes a program's event metadata
        tests: 
          - not_null: *recent_date_filter
      - name: EVENT_TYPE
        description: "{{ doc('event_type') }}"
      - name: _INSERTED_TIMESTAMP
        description: "{{ doc('_inserted_timestamp') }}"
        tests: 
          - not_null
      - name: DECODED_LOGS_ID
        description: '{{ doc("pk") }}'
        tests: 
          - not_null: *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_decoded_logs__invocation_id
              <<: *recent_date_filter