Skip to content

Commit

Permalink
Added Type-II Dimensional Models and the corresponding yml files with…
Browse files Browse the repository at this point in the history
… tests for the Soroban Contract tables
  • Loading branch information
harsha-stellar-data committed Oct 31, 2024
1 parent f40c4e4 commit 225f74a
Show file tree
Hide file tree
Showing 24 changed files with 1,157 additions and 12 deletions.
2 changes: 1 addition & 1 deletion models/intermediate/int_incr_contract_code.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
materialized = 'incremental',
unique_key = ['ledger_key_hash', 'closed_at'],
cluster_by = ["ledger_key_hash", "closed_at"],
tags = ["soroban_analytics"]
tags = ["soroban_analytics", "intermediate", "daily"]
)
}}
/*
Expand Down
103 changes: 103 additions & 0 deletions models/intermediate/int_incr_contract_code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
version: 2

models:
- name: int_incr_contract_code
description: "This intermediate model handles the incremental loading of contract code data from the staging layer."
meta:
owner: "Data Team"
update_schedule: "daily"
description: "Incremental model for contract code with daily updates"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- ledger_key_hash
- closed_at
meta:
description: "Tests the uniqueness combination of contract code tracking fields"
columns:
- name: ledger_key_hash
description: '{{ doc("ledger_key_hash") }}'
tests:
- not_null

- name: contract_code_hash
description: '{{ doc("contract_code_hash") }}'
tests:
- not_null

- name: last_modified_ledger
description: '{{ doc("last_modified_ledger") }}'
tests:
- not_null

- name: ledger_entry_change
description: '{{ doc("ledger_entry_change") }}'
tests:
- not_null
- incremental_accepted_values:
values: [0, 1, 2]

- name: ledger_sequence
description: '{{ doc("ledger_sequence") }}'
tests:
- not_null

- name: deleted
description: '{{ doc("deleted") }}'
tests:
- not_null

- name: closed_at
description: '{{ doc("closed_at") }}'
tests:
- not_null

- name: n_instructions
description: '{{ doc("n_instructions") }}'

- name: n_functions
description: '{{ doc("n_functions") }}'

- name: n_globals
description: '{{ doc("n_globals") }}'

- name: n_table_entries
description: '{{ doc("n_table_entries") }}'

- name: n_types
description: '{{ doc("n_types") }}'

- name: n_data_segments
description: '{{ doc("n_data_segments") }}'

- name: n_elem_segments
description: '{{ doc("n_elem_segments") }}'

- name: n_imports
description: '{{ doc("n_imports") }}'

- name: n_exports
description: '{{ doc("n_exports") }}'

- name: n_data_segment_bytes
description: '{{ doc("n_data_segment_bytes") }}'

- name: batch_id
description: '{{ doc("batch_id") }}'
tests:
- not_null

- name: batch_run_date
description: '{{ doc("batch_run_date") }}'
tests:
- not_null

- name: airflow_start_ts
description: "The timestamp indicating the start of the Airflow task."
tests:
- not_null

- name: dw_load_ts
description: "The timestamp for when the data was loaded into the data warehouse."
tests:
- not_null
2 changes: 1 addition & 1 deletion models/intermediate/int_incr_contract_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"granularity": "month"
},
cluster_by = ['closed_at', 'ledger_key_hash'],
tags = ["soroban_analytics"]
tags = ["soroban_analytics", "intermediate", "daily"]
)
}}
/*
Expand Down
100 changes: 100 additions & 0 deletions models/intermediate/int_incr_contract_data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
version: 2

models:
- name: int_incr_contract_data
description: "This intermediate model handles the incremental loading of contract data from the staging layer."
meta:
owner: "Data Team"
update_schedule: "daily"
description: "Incremental model for contract data with daily updates"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- ledger_key_hash
- closed_at
meta:
description: "Tests the uniqueness combination of contract data tracking fields"

columns:
- name: ledger_key_hash
description: '{{ doc("ledger_key_hash") }}'
tests:
- not_null

- name: contract_id
description: '{{ doc("contract_id") }}'
tests:
- not_null

- name: contract_key_type
description: '{{ doc("contract_key_type") }}'
tests:
- not_null

- name: contract_durability
description: '{{ doc("contract_durability") }}'
tests:
- not_null

- name: last_modified_ledger
description: '{{ doc("last_modified_ledger") }}'
tests:
- not_null

- name: ledger_entry_change
description: '{{ doc("ledger_entry_change") }}'
tests:
- not_null
- incremental_accepted_values:
values: [0, 1, 2]

- name: ledger_sequence
description: '{{ doc("ledger_sequence") }}'
tests:
- not_null

- name: asset_code
description: '{{ doc("asset_code") }}'

- name: asset_issuer
description: '{{ doc("asset_issuer") }}'

- name: asset_type
description: '{{ doc("asset_type") }}'

- name: balance_holder
description: '{{ doc("balance_holder") }}'

- name: balance
description: '{{ doc("balance") }}'

- name: deleted
description: '{{ doc("deleted") }}'

- name: closed_at
description: '{{ doc("closed_at") }}'
tests:
- not_null

- name: batch_insert_ts
description: '{{ doc("batch_insert_ts") }}'

- name: batch_id
description: '{{ doc("batch_id") }}'
tests:
- not_null

- name: batch_run_date
description: '{{ doc("batch_run_date") }}'
tests:
- not_null

- name: airflow_start_ts
description: "The timestamp indicating the start of the Airflow task."
tests:
- not_null

- name: dw_load_ts
description: "Timestamp when the record was loaded."
tests:
- not_null
2 changes: 1 addition & 1 deletion models/intermediate/int_incr_ttl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"granularity": "month"
},
cluster_by = ['closed_at', 'key_hash'],
tags = ["soroban_analytics"]
tags = ["soroban_analytics", "intermediate", "daily"]
)
}}
/*
Expand Down
75 changes: 75 additions & 0 deletions models/intermediate/int_incr_ttl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
version: 2

models:
- name: int_incr_ttl
description: |
This intermediate model handles the incremental loading of ledger time-to-live (TTL)
data from the staging layer. It processes only new or updated data up to the previous day based on `execution_date`.
meta:
owner: "Data Team"
update_schedule: "daily"
description: "Incremental model for TTL data with daily updates"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- key_hash
- closed_at
meta:
description: "Tests the uniqueness combination of TTL tracking fields"
columns:
- name: key_hash
description: '{{ doc("key_hash") }}'
tests:
- not_null

- name: live_until_ledger_seq
description: '{{ doc("live_until_ledger_seq") }}'
tests:
- not_null

- name: last_modified_ledger
description: '{{ doc("last_modified_ledger") }}'
tests:
- not_null

- name: ledger_entry_change
description: '{{ doc("ledger_entry_change") }}'
tests:
- not_null
- incremental_accepted_values:
values: [0, 1, 2]

- name: ledger_sequence
description: '{{ doc("ledger_sequence") }}'
tests:
- not_null

- name: deleted
description: '{{ doc("deleted") }}'
tests:
- not_null

- name: closed_at
description: '{{ doc("closed_at") }}'
tests:
- not_null

- name: batch_id
description: '{{ doc("batch_id") }}'
tests:
- not_null

- name: batch_run_date
description: '{{ doc("batch_run_date") }}'
tests:
- not_null

- name: airflow_start_ts
description: "The timestamp indicating the start of the Airflow task."
tests:
- not_null

- name: dw_load_ts
description: "The timestamp for when the data was loaded into the data warehouse."
tests:
- not_null
2 changes: 1 addition & 1 deletion models/intermediate/int_transform_contract_code.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
materialized = 'table',
unique_key = ['ledger_key_hash', 'closed_at'],
cluster_by = ["ledger_key_hash", "closed_at", "row_hash"],
tags = ["soroban_analytics"]
tags = ["soroban_analytics", "intermediate", "daily"]
)
}}

Expand Down
Loading

0 comments on commit 225f74a

Please sign in to comment.