version: 2
models:
  - name: silver__nft_sales_solsniper_cnft_onchain
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - TX_ID
            - LEAF_INDEX
    recent_date_filter: &recent_date_filter
      config:
        where: _inserted_timestamp >= current_date - 7
    columns:
      - name: BLOCK_TIMESTAMP
        description: "{{ doc('block_timestamp') }}"
        data_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') }}"
        data_tests:
          - not_null: *recent_date_filter
      - name: TX_ID
        description: "{{ doc('tx_id') }}"
        data_tests:
          - not_null: *recent_date_filter
          - dbt_utils.relationships_where:
              name: dbt_utils_relationships_where_silver__sales_solsniper_cnft_onchain_sales_solsniper_final_tx_id
              to: ref('silver__nft_sales_solsniper_cnft')
              field: tx_id
              from_condition: "_inserted_timestamp between current_date - 7 and current_timestamp() - INTERVAL '12 HOUR'"
              to_condition: "_inserted_timestamp between current_date - 7 and current_timestamp() - INTERVAL '12 HOUR'"
      - name: SUCCEEDED
        description: "{{ doc('tx_succeeded') }}"
        data_tests:
          - not_null: *recent_date_filter
      - name: INDEX
        description: "{{ doc('event_index') }}"
        data_tests:  
          - not_null: *recent_date_filter
      - name: INNER_INDEX
        description: "{{ doc('inner_index') }}"
      - name: PROGRAM_ID 
        description: "{{ doc('program_id') }}"
        data_tests: 
          - not_null: *recent_date_filter
      - name: PURCHASER
        description: "{{ doc('purchaser') }}"
        data_tests: 
          - not_null: *recent_date_filter
      - name: SELLER
        description: "{{ doc('seller') }}"
        data_tests: 
          - not_null: *recent_date_filter
      - name: SALES_AMOUNT
        description: "{{ doc('sales_amount') }}"
        data_tests: 
          - not_null: *recent_date_filter
      - name: TREE_AUTHORITY
        description: "{{ doc('tree_authority') }}"
        data_tests: 
          - not_null: *recent_date_filter
      - name: MERKLE_TREE
        description: "{{ doc('merkle_tree') }}"
        data_tests: 
          - not_null: *recent_date_filter
      - name: LEAF_INDEX
        description: "{{ doc('leaf_index') }}"
        data_tests: 
          - not_null: *recent_date_filter
      - name: _INSERTED_TIMESTAMP
        description: "{{ doc('_inserted_timestamp') }}"
        data_tests: 
          - not_null
