diff --git a/.github/workflows/diff-quality.yml b/.github/workflows/diff-quality.yml index 4541b58..84868f6 100644 --- a/.github/workflows/diff-quality.yml +++ b/.github/workflows/diff-quality.yml @@ -68,4 +68,4 @@ jobs: - name: Checkout source branch and diff quality run: | git checkout ${{ github.head_ref }} - diff-quality --violations=sqlfluff --compare-branch=origin/master --fail-under=95 + diff-quality --violations=sqlfluff --exclude incremental_accepted_values.sql --compare-branch=origin/master --fail-under=95 diff --git a/models/staging/stg_account_signers.yml b/models/staging/stg_account_signers.yml new file mode 100644 index 0000000..6d3ae9a --- /dev/null +++ b/models/staging/stg_account_signers.yml @@ -0,0 +1,92 @@ +version: 2 + +models: + - name: stg_account_signers + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + - incremental_unique_combination_of_columns: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + combination_of_columns: + - account_id + - signer + - ledger_sequence + - last_modified_ledger + meta: + description: "Tests the uniqueness combination of: account_id, signer, ledger_sequence and last_modified_ledger" + columns: + - name: account_id + description: '{{ doc("account_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: signer + description: '{{ doc("signer") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: weight + description: '{{ doc("weight") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: sponsor + description: '{{ doc("sponsor") }}' + - name: last_modified_ledger + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: ledger_entry_change + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: [0, 1, 2] + + - name: deleted + description: '{{ doc("deleted") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: closed_at + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: ledger_sequence + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: airflow_start_ts diff --git a/models/staging/stg_accounts.yml b/models/staging/stg_accounts.yml new file mode 100644 index 0000000..8d56516 --- /dev/null +++ b/models/staging/stg_accounts.yml @@ -0,0 +1,172 @@ +version: 2 + +models: + - name: stg_accounts + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + - incremental_unique_combination_of_columns: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + combination_of_columns: + - account_id + - sequence_number + - ledger_entry_change + - last_modified_ledger + meta: + description: "Tests the uniqueness combination of: account_id, sequence_number, ledger_entry_change and last_modified_ledger." + columns: + - name: account_id + description: '{{ doc("account_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: balance + description: '{{ doc("balance") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: buying_liabilities + description: '{{ doc("buying_liabilities") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: selling_liabilities + description: '{{ doc("selling_liabilities") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: sequence_number + description: '{{ doc("sequence_number") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: num_subentries + description: '{{ doc("num_subentries") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: inflation_destination + description: '{{ doc("inflation_destination") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: flags + description: '{{ doc("flags_accounts_balances") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: home_domain + description: '{{ doc("home_domain") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: master_weight + description: '{{ doc("master_weight") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: threshold_low + description: '{{ doc("threshold_low") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: threshold_medium + description: '{{ doc("threshold_medium") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: threshold_high + description: '{{ doc("threshold_high") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: last_modified_ledger + description: '{{ doc("last_modified_ledger") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: ledger_entry_change + description: '{{ doc("ledger_entry_change") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: [0, 1, 2] + + - name: deleted + description: '{{ doc("deleted") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: sponsor + description: '{{ doc("sponsor") }}' + - name: num_sponsored + description: '{{ doc("num_sponsored") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: num_sponsoring + description: '{{ doc("num_sponsoring") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: sequence_ledger + description: '{{ doc("sequence_ledger") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: closed_at + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: ledger_sequence + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: airflow_start_ts diff --git a/models/staging/stg_claimable_balances.yml b/models/staging/stg_claimable_balances.yml new file mode 100644 index 0000000..6fad69d --- /dev/null +++ b/models/staging/stg_claimable_balances.yml @@ -0,0 +1,153 @@ +version: 2 + +models: + - name: stg_claimable_balances + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + - incremental_unique_combination_of_columns: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + combination_of_columns: + - balance_id + - ledger_entry_change + meta: + description: "Tests the uniqueness combination of: balance_id and ledger_entry_change." + columns: + - name: balance_id + description: '{{ doc("balance_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: claimants + description: '{{ doc("claimants") }}' + + - name: claimants.destination + description: '{{ doc("claimants_destination") }}' + + - name: claimants.predicate + description: '{{ doc("claimants_predicate") }}' + + - name: claimants.predicate.unconditional + description: '{{ doc("claimants_predicate_unconditional") }}' + + - name: claimants.predicate.abs_before + description: '{{ doc("claimants_predicate_abs_before") }}' + + - name: claimants.predicate.rel_before + description: '{{ doc("claimants_predicate_rel_before") }}' + + - name: claimants.predicate.abs_before_epoch + description: '{{ doc("claimants_predicate_abs_before_epoch") }}' + + - name: asset_type + description: '{{ doc("asset_type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: ["credit_alphanum4", "credit_alphanum12", "native"] + quote: true + + - name: asset_code + description: '{{ doc("asset_code") }}' + + - name: asset_issuer + description: '{{ doc("asset_issuer") }}' + + - name: asset_id + description: '{{ doc("asset_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_amount + description: '{{ doc("asset_amount") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: sponsor + description: '{{ doc("sponsor") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: flags + description: '{{ doc("flags_accounts_balances") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: last_modified_ledger + description: '{{ doc("last_modified_ledger") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_entry_change + description: '{{ doc("ledger_entry_change") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: [0, 1, 2] + + - name: deleted + description: '{{ doc("deleted") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: closed_at + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_sequence + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: airflow_start_ts diff --git a/models/staging/stg_config_settings.yml b/models/staging/stg_config_settings.yml new file mode 100644 index 0000000..1d6c37b --- /dev/null +++ b/models/staging/stg_config_settings.yml @@ -0,0 +1,200 @@ +version: 2 + +models: + - name: stg_config_settings + tests: + - incremental_unique_combination_of_columns: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + combination_of_columns: + - config_setting_id + - last_modified_ledger + - ledger_entry_change + meta: + description: "Tests the uniqueness combination of: config_setting_id, last_modified_ledger and ledger_entry_change." + columns: + - name: config_setting_id + description: '{{ doc("config_setting_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: contract_max_size_bytes + description: '{{ doc("contract_max_size_bytes") }}' + + - name: ledger_max_instructions + description: '{{ doc("ledger_max_instructions") }}' + + - name: tx_max_instructions + description: '{{ doc("tx_max_instructions") }}' + + - name: fee_rate_per_instructions_increment + description: '{{ doc("fee_rate_per_instructions_increment") }}' + + - name: tx_memory_limit + description: '{{ doc("tx_memory_limit") }}' + + - name: ledger_max_read_ledger_entries + description: '{{ doc("ledger_max_read_ledger_entries") }}' + + - name: ledger_max_read_bytes + description: '{{ doc("ledger_max_read_bytes") }}' + + - name: ledger_max_write_ledger_entries + description: '{{ doc("ledger_max_write_ledger_entries") }}' + + - name: ledger_max_write_bytes + description: '{{ doc("ledger_max_write_bytes") }}' + + - name: tx_max_read_ledger_entries + description: '{{ doc("tx_max_read_ledger_entries") }}' + + - name: tx_max_read_bytes + description: '{{ doc("tx_max_read_bytes") }}' + + - name: tx_max_write_ledger_entries + description: '{{ doc("tx_max_write_ledger_entries") }}' + + - name: tx_max_write_bytes + description: '{{ doc("tx_max_write_bytes") }}' + + - name: fee_read_ledger_entry + description: '{{ doc("fee_read_ledger_entry") }}' + + - name: fee_write_ledger_entry + description: '{{ doc("fee_write_ledger_entry") }}' + + - name: fee_read_1kb + description: '{{ doc("fee_read_1kb") }}' + + - name: bucket_list_target_size_bytes + description: '{{ doc("bucket_list_target_size_bytes") }}' + + - name: write_fee_1kb_bucket_list_low + description: '{{ doc("write_fee_1kb_bucket_list_low") }}' + + - name: write_fee_1kb_bucket_list_high + description: '{{ doc("write_fee_1kb_bucket_list_high") }}' + + - name: bucket_list_write_fee_growth_factor + description: '{{ doc("bucket_list_write_fee_growth_factor") }}' + + - name: fee_historical_1kb + description: '{{ doc("fee_historical_1kb") }}' + + - name: tx_max_contract_events_size_bytes + description: '{{ doc("tx_max_contract_events_size_bytes") }}' + + - name: fee_contract_events_1kb + description: '{{ doc("fee_contract_events_1kb") }}' + + - name: ledger_max_txs_size_bytes + description: '{{ doc("ledger_max_txs_size_bytes") }}' + + - name: tx_max_size_bytes + description: '{{ doc("tx_max_size_bytes") }}' + + - name: fee_tx_size_1kb + description: '{{ doc("fee_tx_size_1kb") }}' + + - name: contract_cost_params_cpu_insns + description: '{{ doc("contract_cost_params_cpu_insns") }}' + + - name: contract_cost_params_mem_bytes + description: '{{ doc("contract_cost_params_mem_bytes") }}' + + - name: contract_data_key_size_bytes + description: '{{ doc("contract_data_key_size_bytes") }}' + + - name: contract_data_entry_size_bytes + description: '{{ doc("contract_data_entry_size_bytes") }}' + + - name: max_entry_ttl + description: '{{ doc("max_entry_ttl") }}' + + - name: min_temp_entry_ttl + description: '{{ doc("min_temp_entry_ttl") }}' + + - name: min_persistent_entry_ttl + description: '{{ doc("min_persistent_entry_ttl") }}' + + - name: auto_bump_ledgers + description: '{{ doc("auto_bump_ledgers") }}' + + - name: persistent_rent_rate_denominator + description: '{{ doc("persistent_rent_rate_denominator") }}' + + - name: temp_rent_rate_denominator + description: '{{ doc("temp_rent_rate_denominator") }}' + + - name: max_entries_to_ttl + description: '{{ doc("max_entries_to_ttl") }}' + + - name: bucket_list_size_window_sample_size + description: '{{ doc("bucket_list_size_window_sample_size") }}' + + - name: eviction_scan_size + description: '{{ doc("eviction_scan_size") }}' + + - name: starting_eviction_scan_level + description: '{{ doc("starting_eviction_scan_level") }}' + + - name: ledger_max_tx_count + description: '{{ doc("ledger_max_tx_count") }}' + + - name: bucket_list_size_window + description: '{{ doc("bucket_list_size_window") }}' + + - name: last_modified_ledger + description: '{{ doc("last_modified_ledger") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_entry_change + description: '{{ doc("ledger_entry_change") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: [0, 1, 2] + + - name: deleted + description: '{{ doc("deleted") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: closed_at + description: '{{ doc("closed_at") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" diff --git a/models/staging/stg_contract_code.yml b/models/staging/stg_contract_code.yml new file mode 100644 index 0000000..e14520c --- /dev/null +++ b/models/staging/stg_contract_code.yml @@ -0,0 +1,151 @@ +version: 2 + +models: + - name: stg_contract_code + tests: + - incremental_unique_combination_of_columns: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + combination_of_columns: + - contract_code_hash + - last_modified_ledger + - ledger_entry_change + meta: + description: "Tests the uniqueness combination of: contract_code_hash, last_modified_ledger, and ledger_entry_change." + columns: + - name: contract_code_hash + description: '{{ doc("contract_code_hash") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: contract_code_ext_v + description: '{{ doc("contract_code_ext_v") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: last_modified_ledger + description: '{{ doc("last_modified_ledger") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: n_data_segment_bytes + description: '{{ doc("n_data_segment_bytes") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: n_data_segments + description: '{{ doc("n_data_segments") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: n_elem_segments + description: '{{ doc("n_elem_segments") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: n_exports + description: '{{ doc("n_exports") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: n_functions + description: '{{ doc("n_functions") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: n_globals + description: '{{ doc("n_globals") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: n_imports + description: '{{ doc("n_imports") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: n_instructions + description: '{{ doc("n_instructions") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: n_table_entries + description: '{{ doc("n_table_entries") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: n_types + description: '{{ doc("n_types") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_entry_change + description: '{{ doc("ledger_entry_change") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: [0, 1, 2] + + - name: deleted + description: '{{ doc("deleted") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: closed_at + description: '{{ doc("closed_at") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" diff --git a/models/staging/stg_contract_data.yml b/models/staging/stg_contract_data.yml new file mode 100644 index 0000000..4f55f95 --- /dev/null +++ b/models/staging/stg_contract_data.yml @@ -0,0 +1,148 @@ +version: 2 + +models: + - name: stg_contract_data + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + - incremental_unique_combination_of_columns: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + combination_of_columns: + - ledger_key_hash + - last_modified_ledger + - ledger_entry_change + meta: + description: "Tests the uniqueness combination of: ledger_key_hash, last_modified_ledger, and ledger_entry_change." + columns: + - name: contract_id + description: '{{ doc("contract_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: contract_key_type + description: '{{ doc("contract_key_type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: contract_durability + description: '{{ doc("contract_durability") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_code + description: '{{ doc("asset_code") }}' + + - name: asset_issuer + description: '{{ doc("asset_issuer") }}' + + - name: asset_type + description: '{{ doc("asset_type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: balance_holder + description: '{{ doc("balance_holder") }}' + + - name: balance + description: '{{ doc("balance") }}' + + - name: last_modified_ledger + description: '{{ doc("last_modified_ledger") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_entry_change + description: '{{ doc("ledger_entry_change") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: [0, 1, 2] + + - name: deleted + description: '{{ doc("deleted") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: key + description: '{{ doc("key") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: key_decoded + description: '{{ doc("key_decoded") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: val + description: '{{ doc("val") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: val_decoded + description: '{{ doc("val_decoded") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: contract_data_xdr + description: '{{ doc("contract_data_xdr") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: closed_at + description: '{{ doc("closed_at") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" diff --git a/models/staging/stg_history_assets.yml b/models/staging/stg_history_assets.yml new file mode 100644 index 0000000..583b416 --- /dev/null +++ b/models/staging/stg_history_assets.yml @@ -0,0 +1,66 @@ +version: 2 + +models: + - name: stg_history_assets + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + - incremental_unique_combination_of_columns: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + combination_of_columns: + - asset_type + - asset_code + - asset_issuer + meta: + description: "Tests the uniqueness combination of: asset_type, asset_code, and asset_issuer." + columns: + - name: asset_id + description: '{{ doc("asset_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_type + description: '{{ doc("asset_type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: ["credit_alphanum4", "credit_alphanum12", "native"] + quote: true + + - name: asset_code + description: '{{ doc("asset_code") }}' + + - name: asset_issuer + description: '{{ doc("asset_issuer") }}' + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" diff --git a/models/staging/stg_history_effects.yml b/models/staging/stg_history_effects.yml new file mode 100644 index 0000000..f669581 --- /dev/null +++ b/models/staging/stg_history_effects.yml @@ -0,0 +1,340 @@ +version: 2 + +models: + - name: stg_history_effects + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + columns: + - name: address + description: '{{ doc("address") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: address_muxed + description: '{{ doc("address_muxed") }}' + + - name: operation_id + description: '{{ doc("operation_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: id + description: '{{ doc("id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_sequence + description: '{{ doc("ledger_sequence") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: type + description: '{{ doc("type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: type_string + description: '{{ doc("type_string") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: details + description: '{{ doc("details_effects") }}' + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: details.liquidity_pool + description: '{{ doc("details_liquidity_pool") }}' + + - name: details.liquidity_pool.fee_bp + description: '{{ doc("details_liquidity_pool_fee_bp") }}' + + - name: details.liquidity_pool.id + description: '{{ doc("details_liquidity_pool_id") }}' + + - name: details.liquidity_pool.total_shares + description: '{{ doc("details_liquidity_pool_total_shares") }}' + + - name: details.liquidity_pool.total_trustlines + description: '{{ doc("details_liquidity_pool_total_trustlines") }}' + + - name: details.liquidity_pool.type + description: '{{ doc("details_liquidity_pool_type") }}' + + - name: details.liquidity_pool.reserves + description: '{{ doc("details_liquidity_pool_reserves") }}' + + - name: details.liquidity_pool.reserves.asset + description: '{{ doc("details_asset") }}' + + - name: details.liquidity_pool.reserves.amount + description: '{{ doc("details_amount") }}' + + - name: details.reserves_received + description: '{{ doc("details_reserves_received") }}' + + - name: details.reserves_received.asset + description: '{{ doc("details_asset") }}' + + - name: details.reserves_received.amount + description: '{{ doc("details_amount") }}' + + - name: details.reserves_deposited + description: '{{ doc("details_reserves_deposited") }}' + + - name: details.reserves_deposited.asset + description: '{{ doc("details_asset") }}' + + - name: details.reserves_deposited.amount + description: '{{ doc("details_amount") }}' + + - name: details.reserves_revoked + description: '{{ doc("details_reserves_revoked") }}' + + - name: details.reserves_revoked.asset + description: '{{ doc("details_asset") }}' + + - name: details.reserves_revoked.amount + description: '{{ doc("details_amount") }}' + + - name: details.reserves_revoked.claimable_balance_id + description: '{{ doc("details_reserves_revoked_claimable_balance_id") }}' + + - name: details.bought + description: '{{ doc("details_bought") }}' + + - name: details.bought.asset + description: '{{ doc("details_asset") }}' + + - name: details.bought.amount + description: '{{ doc("details_amount") }}' + + - name: details.sold + description: '{{ doc("details_sold") }}' + + - name: details.sold.asset + description: '{{ doc("details_asset") }}' + + - name: details.sold.amount + description: '{{ doc("details_amount") }}' + + - name: details.shares_revoked + description: '{{ doc("details_shares_revoked") }}' + + - name: details.shares_received + description: '{{ doc("details_shares_received") }}' + + - name: details.shares_redeemed + description: '{{ doc("details_shares_redeemed") }}' + + - name: details.liquidity_pool_id + description: '{{ doc("details_liquidity_pool_id") }}' + + - name: details.balance_id + description: '{{ doc("details_balance_id") }}' + + - name: details.new_seq + description: '{{ doc("details_new_seq") }}' + + - name: details.name + description: '{{ doc("details_name") }}' + + - name: details.value + description: '{{ doc("details_value") }}' + + - name: details.trustor + description: '{{ doc("details_trustor") }}' + + - name: details.limit + description: '{{ doc("details_limit") }}' + + - name: details.inflation_destination + description: '{{ doc("details_inflation_destination") }}' + + - name: details.authorized_flag + description: '{{ doc("details_authorized_flag") }}' + + - name: details.auth_immutable_flag + description: '{{ doc("details_auth_immutable_flag") }}' + + - name: details.authorized_to_maintain_liabilites + description: '{{ doc("details_authorized_to_maintain_liabilites") }}' + + - name: details.auth_revocable_flag + description: '{{ doc("details_auth_revocable_flag") }}' + + - name: details.auth_required_flag + description: '{{ doc("details_auth_required_flag") }}' + + - name: details.auth_clawback_enabled_flag + description: '{{ doc("details_auth_clawback_enabled_flag") }}' + + - name: details.claimable_balance_clawback_enabled_flag + description: '{{ doc("details_claimable_balance_clawback_enabled_flag") }}' + + - name: details.clawback_enabled_flag + description: '{{ doc("details_clawback_enabled_flag") }}' + + - name: details.high_threshold + description: '{{ doc("details_high_threshold") }}' + + - name: details.med_threshold + description: '{{ doc("details_med_threshold") }}' + + - name: details.low_threshold + description: '{{ doc("details_low_threshold") }}' + + - name: details.home_domain + description: '{{ doc("details_home_domain") }}' + + - name: details.asset_issuer + description: '{{ doc("details_asset_issuer") }}' + + - name: details.asset + description: '{{ doc("details_asset") }}' + + - name: details.asset_code + description: '{{ doc("details_asset_code") }}' + + - name: details.asset_type + description: '{{ doc("details_asset_type") }}' + + - name: details.signer + description: '{{ doc("details_signer") }}' + + - name: details.sponsor + description: '{{ doc("details_sponsor") }}' + + - name: details.new_sponsor + description: '{{ doc("details_new_sponsor") }}' + + - name: details.former_sponsor + description: '{{ doc("details_former_sponsor") }}' + + - name: details.weight + description: '{{ doc("details_weight") }}' + + - name: details.public_key + description: '{{ doc("details_public_key") }}' + + - name: details.amount + description: '{{ doc("details_amount") }}' + + - name: details.starting_balance + description: '{{ doc("details_starting_balance") }}' + + - name: details.seller + description: '{{ doc("details_seller") }}' + + - name: details.seller_muxed + description: '{{ doc("details_seller_muxed") }}' + + - name: details.seller_muxed_id + description: '{{ doc("details_seller_muxed_id") }}' + + - name: details.offer_id + description: '{{ doc("details_offer_id") }}' + + - name: details.sold_amount + description: '{{ doc("details_amount") }}' + + - name: details.sold_asset_type + description: '{{ doc("details_asset_type") }}' + + - name: details.sold_asset_code + description: '{{ doc("details_asset_code") }}' + + - name: details.sold_asset_issuer + description: '{{ doc("details_asset_issuer") }}' + + - name: details.bought_asset_type + description: '{{ doc("details_asset_type") }}' + + - name: details.bought_asset_code + description: '{{ doc("details_asset_code") }}' + + - name: details.bought_asset_issuer + description: '{{ doc("details_asset_issuer") }}' + + - name: details.bought_amount + description: '{{ doc("details_amount") }}' + + - name: details.data_name + description: '{{ doc("details_data_name") }}' + + - name: details.predicate + description: '{{ doc("claimants_predicate") }}' + + - name: details.predicate.abs_before + description: '{{ doc("claimants_predicate_abs_before") }}' + + - name: details.predicate.rel_before + description: '{{ doc("claimants_predicate_rel_before") }}' + + - name: details.predicate.unconditional + description: '{{ doc("claimants_predicate_unconditional") }}' + + - name: details.predicate.abs_before_epoch + description: '{{ doc("claimants_predicate_abs_before_epoch") }}' + + - name: details.contract + description: '{{ doc("contract_id") }}' + + - name: details.contract_event_type + description: '{{ doc("contract_event_type") }}' + + - name: details.extend_to + description: '{{ doc("details_extend_to") }}' + + - name: details.entries + description: '{{ doc("details_entries") }}' + + - name: index + description: '{{ doc("index") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: closed_at + description: '{{ doc("closed_at") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" diff --git a/models/staging/stg_history_ledgers.yml b/models/staging/stg_history_ledgers.yml new file mode 100644 index 0000000..117b888 --- /dev/null +++ b/models/staging/stg_history_ledgers.yml @@ -0,0 +1,178 @@ +version: 2 + +models: + - name: stg_history_ledgers + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + columns: + - name: sequence + description: '{{ doc("sequence") }}' + tests: + - incremental_unique: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_hash + description: '{{ doc("ledger_hash") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: previous_ledger_hash + description: '{{ doc("previous_ledger_hash") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: transaction_count + description: '{{ doc("transaction_count") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_operation_count + description: '{{ doc("operation_count") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: closed_at + description: '{{ doc("closed_at") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_id + description: '{{ doc("ledger_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: total_coins + description: '{{ doc("total_coins") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: fee_pool + description: '{{ doc("fee_pool") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: base_fee + description: '{{ doc("base_fee") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: base_reserve + description: '{{ doc("base_reserve") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: max_tx_set_size + description: '{{ doc("max_tx_set_size") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: protocol_version + description: '{{ doc("protocol_version") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_header + description: '{{ doc("ledger_header") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: successful_transaction_count + description: '{{ doc("successful_transaction_count") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: failed_transaction_count + description: '{{ doc("failed_transaction_count") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: tx_set_operation_count + description: '{{ doc("tx_set_operation_count") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: soroban_fee_write_1kb + description: '{{ doc("soroban_fee_write_1kb") }}' + + - name: node_id + description: '{{ doc("node_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: signature + description: '{{ doc("signature") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: soroban_fee_write_1kb + description: '{{ doc("soroban_fee_write_1kb") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" diff --git a/models/staging/stg_history_operations.yml b/models/staging/stg_history_operations.yml new file mode 100644 index 0000000..6fe80ef --- /dev/null +++ b/models/staging/stg_history_operations.yml @@ -0,0 +1,447 @@ +version: 2 + +models: + - name: stg_history_operations + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + columns: + - name: op_id + description: '{{ doc("operation_id") }}' + tests: + - incremental_unique: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: op_source_account + description: '{{ doc("source_account") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: op_source_account_muxed + description: '{{ doc("source_account_muxed") }}' + + - name: transaction_id + description: '{{ doc("op_transaction_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_sequence + description: '{{ doc("ledger_sequence") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: type + description: '{{ doc("type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: type_string + description: '{{ doc("type_string") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: details + description: '{{ doc("details") }}' + + - name: details.account + description: '{{ doc("details_account") }}' + + - name: details.account_muxed + description: '{{ doc("details_account_muxed") }}' + + - name: details.account_muxed_id + description: '{{ doc("details_account_muxed_id") }}' + + - name: details.account_id + description: '{{ doc("details_account_id") }}' + + - name: details.amount + description: '{{ doc("details_amount") }}' + + - name: details.asset + description: '{{ doc("details_asset") }}' + + - name: details.asset_id + description: '{{ doc("details_asset_id") }}' + + - name: details.buying_asset_id + description: '{{ doc("details_buying_asset_id") }}' + + - name: details.selling_asset_id + description: '{{ doc("details_selling_asset_id") }}' + + - name: details.source_asset_id + description: '{{ doc("details_source_asset_id") }}' + + - name: details.reserve_a_asset_id + description: '{{ doc("details_reserve_a_asset_id") }}' + + - name: details.reserve_b_asset_id + description: '{{ doc("details_reserve_b_asset_id") }}' + + - name: details.ledger_key_hash + description: '{{ doc("ledger_key_hash") }}' + + - name: details.ledgers_to_expire + description: '{{ doc("details_ledgers_to_expire") }}' + + - name: details.asset_code + description: '{{ doc("details_asset_code") }}' + + - name: details.asset_issuer + description: '{{ doc("details_asset_issuer") }}' + + - name: details.asset_type + description: '{{ doc("details_asset_type") }}' + + - name: details.authorize + description: '{{ doc("details_authorize") }}' + + - name: details.balance_id + description: '{{ doc("details_balance_id") }}' + + - name: details.buying_asset_code + description: '{{ doc("details_buying_asset_code") }}' + + - name: details.buying_asset_issuer + description: '{{ doc("details_buying_asset_issuer") }}' + + - name: details.buying_asset_type + description: '{{ doc("details_buying_asset_type") }}' + + - name: details.claimable_balance_id + description: '{{ doc("details_claimable_balance_id") }}' + + - name: details.claimant + description: '{{ doc("details_claimant") }}' + + - name: details.claimant_muxed + description: '{{ doc("details_claimant_muxed") }}' + + - name: details.claimant_muxed_id + description: '{{ doc("details_claimant_muxed_id") }}' + + - name: details.claimants + description: '{{ doc("details_claimants") }}' + + - name: details.data_account_id + description: '{{ doc("details_data_account_id") }}' + + - name: details.data_name + description: '{{ doc("details_data_name") }}' + + - name: details.from + description: '{{ doc("details_from") }}' + + - name: details.from_muxed + description: '{{ doc("details_from_muxed") }}' + + - name: details.from_muxed_id + description: '{{ doc("details_from_muxed_id") }}' + + - name: details.funder + description: '{{ doc("details_funder") }}' + + - name: details.funder_muxed + description: '{{ doc("details_funder_muxed") }}' + + - name: details.funder_muxed_id + description: '{{ doc("details_funder_muxed_id") }}' + + - name: details.high_threshold + description: '{{ doc("details_high_threshold") }}' + + - name: details.home_domain + description: '{{ doc("details_home_domain") }}' + + - name: details.inflation_dest + description: '{{ doc("details_inflation_dest") }}' + + - name: details.into + description: '{{ doc("details_into") }}' + + - name: details.into_muxed + description: '{{ doc("details_into_muxed") }}' + + - name: details.into_muxed_id + description: '{{ doc("details_into_muxed_id") }}' + + - name: details.limit + description: '{{ doc("details_limit") }}' + + - name: details.low_threshold + description: '{{ doc("details_low_threshold") }}' + + - name: details.master_key_weight + description: '{{ doc("details_master_key_weight") }}' + + - name: details.med_threshold + description: '{{ doc("details_med_threshold") }}' + + - name: details.name + description: '{{ doc("details_name") }}' + + - name: details.offer_id + description: '{{ doc("details_offer_id") }}' + + - name: details.path + description: '{{ doc("details_path") }}' + + - name: details.price + description: '{{ doc("details_price") }}' + + - name: details.price_r + description: '{{ doc("details_price_r") }}' + + - name: details.selling_asset_code + description: '{{ doc("details_selling_asset_code") }}' + + - name: details.selling_asset_issuer + description: '{{ doc("details_selling_asset_issuer") }}' + + - name: details.selling_asset_type + description: '{{ doc("details_selling_asset_type") }}' + + - name: details.set_flags + description: '{{ doc("details_set_flags") }}' + + - name: details.set_flags_s + description: '{{ doc("details_set_flags_s") }}' + + - name: details.signer_account_id + description: '{{ doc("details_signer_account_id") }}' + + - name: details.signer_key + description: '{{ doc("details_signer_key") }}' + + - name: details.signer_weight + description: '{{ doc("details_signer_weight") }}' + + - name: details.source_amount + description: '{{ doc("details_source_amount") }}' + + - name: details.source_asset_code + description: '{{ doc("details_source_asset_code") }}' + + - name: details.source_asset_issuer + description: '{{ doc("details_source_asset_issuer") }}' + + - name: details.source_asset_type + description: '{{ doc("details_source_asset_type") }}' + + - name: details.source_max + description: '{{ doc("details_source_max") }}' + + - name: details.starting_balance + description: '{{ doc("details_starting_balance") }}' + + - name: details.to + description: '{{ doc("details_to") }}' + + - name: details.to_muxed + description: '{{ doc("details_to_muxed") }}' + + - name: details.to_muxed_id + description: '{{ doc("details_to_muxed_id") }}' + + - name: details.trustee + description: '{{ doc("details_trustee") }}' + + - name: details.trustee_muxed + description: '{{ doc("details_trustee_muxed") }}' + + - name: details.trustee_muxed_id + description: '{{ doc("details_trustee_muxed_id") }}' + + - name: details.trustline_account_id + description: '{{ doc("details_trustline_account_id") }}' + + - name: details.trustline_asset + description: '{{ doc("details_trustline_asset") }}' + + - name: details.trustor + description: '{{ doc("details_trustor") }}' + + - name: details.trustor_muxed + description: '{{ doc("details_trustor_muxed") }}' + + - name: details.trustor_muxed_id + description: '{{ doc("details_trustor_muxed_id") }}' + + - name: details.value + description: '{{ doc("details_value") }}' + + - name: details.clear_flags + description: '{{ doc("details_clear_flags") }}' + + - name: details.clear_flags_s + description: '{{ doc("details_clear_flags_s") }}' + + - name: details.destination_min + description: '{{ doc("details_destination_min") }}' + + - name: details.bump_to + description: '{{ doc("details_bump_to") }}' + + - name: details.authorize_to_maintain_liabilities + description: '{{ doc("details_authorize_to_maintain_liabilities") }}' + + - name: details.clawback_enabled + description: '{{ doc("details_clawback_enabled") }}' + + - name: details.sponsor + description: '{{ doc("details_sponsor") }}' + + - name: details.sponsored_id + description: '{{ doc("details_sponsored_id") }}' + + - name: details.begin_sponsor + description: '{{ doc("details_begin_sponsor") }}' + + - name: details.begin_sponsor_muxed + description: '{{ doc("details_begin_sponsor_muxed") }}' + + - name: details.begin_sponsor_muxed_id + description: '{{ doc("details_begin_sponsor_muxed_id") }}' + + - name: details.liquidity_pool_id + description: '{{ doc("details_liquidity_pool_id") }}' + + - name: details.reserve_a_asset_type + description: '{{ doc("details_reserve_a_asset_type") }}' + + - name: details.reserve_a_asset_code + description: '{{ doc("details_reserve_a_asset_code") }}' + + - name: details.reserve_a_asset_issuer + description: '{{ doc("details_reserve_a_asset_issuer") }}' + + - name: details.reserve_a_max_amount + description: '{{ doc("details_reserve_a_max_amount") }}' + + - name: details.reserve_a_deposit_amount + description: '{{ doc("details_reserve_a_deposit_amount") }}' + + - name: details.reserve_b_asset_type + description: '{{ doc("details_reserve_b_asset_type") }}' + + - name: details.reserve_b_asset_code + description: '{{ doc("details_reserve_b_asset_code") }}' + + - name: details.reserve_b_asset_issuer + description: '{{ doc("details_reserve_b_asset_issuer") }}' + + - name: details.reserve_b_max_amount + description: '{{ doc("details_reserve_b_max_amount") }}' + + - name: details.reserve_b_deposit_amount + description: '{{ doc("details_reserve_b_deposit_amount") }}' + + - name: details.min_price + description: '{{ doc("details_min_price") }}' + + - name: details.min_price_r + description: '{{ doc("details_min_price_r") }}' + + - name: details.max_price + description: '{{ doc("details_max_price") }}' + + - name: details.max_price_r + description: '{{ doc("details_max_price_r") }}' + + - name: details.shares_received + description: '{{ doc("details_shares_received") }}' + + - name: details.reserve_a_min_amount + description: '{{ doc("details_reserve_a_min_amount") }}' + + - name: details.reserve_a_withdraw_amount + description: '{{ doc("details_reserve_a_withdraw_amount") }}' + + - name: details.reserve_b_min_amount + description: '{{ doc("details_reserve_b_min_amount") }}' + + - name: details.reserve_b_withdraw_amount + description: '{{ doc("details_reserve_b_withdraw_amount") }}' + + - name: details.shares + description: '{{ doc("details_shares") }}' + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: details.asset_balance_changes + description: '{{ doc("details_asset_balance_changes") }}' + + - name: details.parameters + description: '{{ doc("details_parameters") }}' + + - name: details.function + description: '{{ doc("details_function") }}' + + - name: details.address + description: '{{ doc("from_address") }}' + + - name: details.type + description: '{{ doc("details_type") }}' + + - name: details.extend_to + description: '{{ doc("details_extend_to") }}' + + - name: details.contract_id + description: '{{ doc("contract_id") }}' + + - name: details.contract_code_hash + description: '{{ doc("contract_code_hash") }}' + + - name: details.operation_result_code + description: '{{ doc("operation_result_code") }}' + + - name: details.operation_trace_code + description: '{{ doc("operation_trace_code") }}' + + - name: closed_at + description: '{{ doc("closed_at") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: details_json + description: '{{ doc("details") }}' + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" diff --git a/models/staging/stg_history_trades.yml b/models/staging/stg_history_trades.yml new file mode 100644 index 0000000..5147435 --- /dev/null +++ b/models/staging/stg_history_trades.yml @@ -0,0 +1,184 @@ +version: 2 + +models: + - name: stg_history_trades + tests: + - dbt_utils.recency: + datepart: hour + field: cast(ledger_closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + - incremental_unique_combination_of_columns: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + combination_of_columns: + - history_operation_id + - "`order`" + meta: + description: "Tests the uniqueness combination of: history_operation_id and order." + columns: + - name: history_operation_id + description: '{{ doc("history_operation_id") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: "`order`" + description: '{{ doc("order") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_closed_at + description: '{{ doc("ledger_closed_at") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: selling_account_address + description: '{{ doc("selling_account_address") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: selling_asset_code + description: '{{ doc("trade_selling_asset_code") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: selling_asset_issuer + description: '{{ doc("trade_selling_asset_issuer") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: selling_asset_type + description: '{{ doc("trade_selling_asset_type") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: selling_asset_id + description: '{{ doc("assets_id") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: selling_amount + description: '{{ doc("trade_selling_amount") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: buying_account_address + description: '{{ doc("buying_account_address") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: buying_asset_code + description: '{{ doc("trade_buying_asset_code") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: buying_asset_issuer + description: '{{ doc("trade_buying_asset_issuer") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: buying_asset_type + description: '{{ doc("trade_buying_asset_type") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: buying_asset_id + description: '{{ doc("assets_id") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: buying_amount + description: '{{ doc("trade_buying_amount") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: price_n + description: '{{ doc("trade_price_n") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: price_d + description: '{{ doc("trade_price_d") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: selling_offer_id + description: '{{ doc("selling_offer_id") }}' + + - name: buying_offer_id + description: '{{ doc("buying_offer_id") }}' + + - name: selling_liquidity_pool_id + description: '{{ doc("selling_liquidity_pool_id") }}' + + - name: liquidity_pool_fee + description: '{{ doc("liquidity_pool_fee") }}' + + - name: trade_type + description: '{{ doc("trade_type") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: rounding_slippage + description: '{{ doc("rounding_slippage") }}' + + - name: seller_is_exact + description: '{{ doc("seller_is_exact") }}' + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "ledger_closed_at" + greater_than_equal_to: "2 day" diff --git a/models/staging/stg_history_transactions.yml b/models/staging/stg_history_transactions.yml new file mode 100644 index 0000000..7c5c8e6 --- /dev/null +++ b/models/staging/stg_history_transactions.yml @@ -0,0 +1,229 @@ +version: 2 + +models: + - name: stg_history_transactions + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + columns: + - name: transaction_id + description: '{{ doc("transaction_id") }}' + tests: + - incremental_unique: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: transaction_hash + description: '{{ doc("transaction_hash") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_sequence + description: '{{ doc("ledger_sequence") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: application_order + description: '{{ doc("application_order") }}' + + - name: txn_account + description: '{{ doc("account") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: account_sequence + description: '{{ doc("account_sequence") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: max_fee + description: '{{ doc("max_fee") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: txn_operation_count + description: '{{ doc("transaction_operation_count") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: txn_created_at + description: '{{ doc("created_at") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: memo_type + description: '{{ doc("memo_type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: memo + description: '{{ doc("memo") }}' + + - name: time_bounds + description: '{{ doc("time_bounds") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: successful + description: '{{ doc("successful") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: fee_charged + description: '{{ doc("fee_charged") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: inner_transaction_hash + description: '{{ doc("inner_transaction_hash") }}' + + - name: fee_account + description: '{{ doc("fee_account") }}' + + - name: new_max_fee + description: '{{ doc("new_max_fee") }}' + + - name: account_muxed + description: '{{ doc("account_muxed") }}' + + - name: fee_account_muxed + description: '{{ doc("fee_account_muxed") }}' + + - name: ledger_bounds + description: '{{ doc("ledger_bounds") }}' + + - name: min_account_sequence + description: '{{ doc("min_account_sequence") }}' + + - name: min_account_sequence_age + description: '{{ doc("min_account_sequence_age") }}' + + - name: min_account_sequence_ledger_gap + description: '{{ doc("min_account_sequence_ledger_gap") }}' + + - name: extra_signers + description: '{{ doc("extra_signers") }}' + + - name: tx_signers + description: '{{ doc("tx_signers") }}' + + - name: tx_envelope + description: '{{ doc("tx_envelope") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: tx_result + description: '{{ doc("tx_result") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: tx_meta + description: '{{ doc("tx_meta") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: tx_fee_meta + description: '{{ doc("tx_fee_meta") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: closed_at + description: '{{ doc("closed_at") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: resource_fee + description: '{{ doc("resource_fee") }}' + + - name: soroban_resources_instructions + description: '{{ doc("soroban_resources_instructions") }}' + + - name: soroban_resources_read_bytes + description: '{{ doc("soroban_resources_read_bytes") }}' + + - name: soroban_resources_write_bytes + description: '{{ doc("soroban_resources_read_bytes") }}' + + - name: transaction_result_code + description: '{{ doc("transaction_result_code") }}' + + - name: inclusion_fee_bid + description: '{{ doc("inclusion_fee_bid") }}' + + - name: inclusion_fee_charged + description: '{{ doc("inclusion_fee_charged") }}' + + - name: resource_fee_refund + description: '{{ doc("resource_fee_refund") }}' + + - name: non_refundable_resource_fee_charged + description: '{{ doc("non_refundable_resource_fee_charged") }}' + + - name: refundable_resource_fee_charged + description: '{{ doc("refundable_resource_fee_charged") }}' + + - name: rent_fee_charged + description: '{{ doc("rent_fee_charged") }}' + + - name: refundable_fee + description: '{{ doc("refundable_fee") }}' + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" diff --git a/models/staging/stg_liquidity_pools.yml b/models/staging/stg_liquidity_pools.yml new file mode 100644 index 0000000..5a9ba1d --- /dev/null +++ b/models/staging/stg_liquidity_pools.yml @@ -0,0 +1,171 @@ +version: 2 + +models: + - name: stg_liquidity_pools + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + - incremental_unique_combination_of_columns: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + combination_of_columns: + - liquidity_pool_id + - ledger_entry_change + - last_modified_ledger + meta: + description: "Tests the uniqueness combination of: liquidity_pool_id, ledger_entry_change and last_modified_ledger." + columns: + - name: liquidity_pool_id + description: '{{ doc("liquidity_pool_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: type + description: '{{ doc("pool_type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: fee + description: '{{ doc("fee") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: trustline_count + description: '{{ doc("trustline_count") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: pool_share_count + description: '{{ doc("pool_share_count") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_a_id + description: '{{ doc("asset_a_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_a_type + description: '{{ doc("asset_a_type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_a_code + description: '{{ doc("asset_a_code") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_a_issuer + description: '{{ doc("asset_a_issuer") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_a_amount + description: '{{ doc("asset_a_amount") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_b_id + description: '{{ doc("asset_b_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_b_type + description: '{{ doc("asset_a_type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_b_code + description: '{{ doc("asset_a_code") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_b_issuer + description: '{{ doc("asset_a_issuer") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_b_amount + description: '{{ doc("asset_a_amount") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: last_modified_ledger + description: '{{ doc("last_modified_ledger") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_entry_change + description: '{{ doc("ledger_entry_change") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: [0, 1, 2] + + - name: deleted + description: '{{ doc("deleted") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" diff --git a/models/staging/stg_offers.yml b/models/staging/stg_offers.yml new file mode 100644 index 0000000..e7e14bd --- /dev/null +++ b/models/staging/stg_offers.yml @@ -0,0 +1,184 @@ +version: 2 + +models: + - name: stg_offers + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + - incremental_unique_combination_of_columns: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + combination_of_columns: + - offer_id + - ledger_entry_change + - last_modified_ledger + meta: + description: "Tests the uniqueness combination of: offer_id, ledger_entry_change and last_modified_ledger." + columns: + - name: seller_id + description: '{{ doc("seller_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: offer_id + description: '{{ doc("offer_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: selling_asset_type + description: '{{ doc("asset_type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: selling_asset_code + description: '{{ doc("asset_code") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: selling_asset_issuer + description: '{{ doc("asset_issuer") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: buying_asset_type + description: '{{ doc("asset_type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: buying_asset_code + description: '{{ doc("asset_code") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: buying_asset_issuer + description: '{{ doc("asset_issuer") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: amount + description: '{{ doc("amount") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: pricen + description: '{{ doc("price_n") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: priced + description: '{{ doc("price_d") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: price + description: '{{ doc("price") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: flags + description: '{{ doc("flags_offers") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: last_modified_ledger + description: '{{ doc("last_modified_ledger") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_entry_change + description: '{{ doc("ledger_entry_change") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: [0, 1, 2] + + - name: deleted + description: '{{ doc("deleted") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: sponsor + description: '{{ doc("sponsor") }}' + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: selling_asset_id + description: '{{ doc("assets_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: buying_asset_id + description: '{{ doc("assets_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: closed_at + description: '{{ doc("closed_at") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_sequence + description: '{{ doc("ledger_sequence") }}' + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" diff --git a/models/staging/stg_trust_lines.yml b/models/staging/stg_trust_lines.yml new file mode 100644 index 0000000..b7117a2 --- /dev/null +++ b/models/staging/stg_trust_lines.yml @@ -0,0 +1,162 @@ +version: 2 + +models: + - name: stg_trust_lines + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + - incremental_unique_combination_of_columns: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + combination_of_columns: + - account_id + - asset_code + - asset_issuer + - liquidity_pool_id + - ledger_entry_change + - last_modified_ledger + meta: + description: "Tests the uniqueness combination of: account_id, asset_code, asset_issuer, liquidity_pool_id, ledger_entry_change and last_modified_ledger." + columns: + - name: ledger_key + description: '{{ doc("ledger_key") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - name: account_id + description: '{{ doc("account_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: asset_type + description: '{{ doc("asset_type") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: ["credit_alphanum4", "credit_alphanum12", "pool_share"] + quote: true + + - name: asset_issuer + description: '{{ doc("asset_issuer") }}' + + - name: asset_code + description: '{{ doc("asset_code") }}' + + - name: liquidity_pool_id + description: '{{ doc("liquidity_pool_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: balance + description: '{{ doc("trust_balance") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: trust_line_limit + description: '{{ doc("trust_line_limit") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: buying_liabilities + description: '{{ doc("buying_liabilities") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: selling_liabilities + description: '{{ doc("selling_liabilities") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: flags + description: '{{ doc("flags_trust_lines") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: last_modified_ledger + description: '{{ doc("last_modified_ledger") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_entry_change + description: '{{ doc("ledger_entry_change") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: [0, 1, 2] + + - name: deleted + description: '{{ doc("deleted") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: sponsor + description: '{{ doc("sponsor") }}' + + - name: asset_id + description: asset id + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: closed_at + description: '{{ doc("closed_at") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_sequence + description: '{{ doc("ledger_sequence") }}' + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" diff --git a/models/staging/stg_ttl.yml b/models/staging/stg_ttl.yml new file mode 100644 index 0000000..c892e78 --- /dev/null +++ b/models/staging/stg_ttl.yml @@ -0,0 +1,88 @@ +version: 2 + +models: + - name: stg_ttl + tests: + - dbt_utils.recency: + datepart: hour + field: cast(closed_at as timestamp) + interval: '{{ 1 if target.name == "prod" else 6 }}' + meta: + description: "Monitors the freshness of your table over time, as the expected time between data updates." + - incremental_unique_combination_of_columns: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + combination_of_columns: + - key_hash + - live_until_ledger_seq + - last_modified_ledger + - ledger_entry_change + meta: + description: "Tests the uniqueness combination of: key_hash, live_until_ledger_seq, last_modified_ledger, and ledger_entry_change." + columns: + - name: key_hash + description: '{{ doc("key_hash") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: live_until_ledger_seq + description: '{{ doc("live_until_ledger_seq") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: last_modified_ledger + description: '{{ doc("last_modified_ledger") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: ledger_entry_change + description: '{{ doc("ledger_entry_change") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + - incremental_accepted_values: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + values: [0, 1, 2] + + - name: deleted + description: '{{ doc("deleted") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_id + description: '{{ doc("batch_id") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_run_date + description: '{{ doc("batch_run_date") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: closed_at + description: '{{ doc("closed_at") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" + + - name: batch_insert_ts + description: '{{ doc("batch_insert_ts") }}' + tests: + - incremental_not_null: + date_column_name: "closed_at" + greater_than_equal_to: "2 day" diff --git a/tests/generic/incremental_accepted_values.sql b/tests/generic/incremental_accepted_values.sql index 5e983de..6f1e506 100644 --- a/tests/generic/incremental_accepted_values.sql +++ b/tests/generic/incremental_accepted_values.sql @@ -1,13 +1,18 @@ -{% test incremental_accepted_values(model, column_name, date_column_name, greater_than_equal_to, less_than_equal_to, condition, values=[]) %} +{% test incremental_accepted_values(model, column_name, date_column_name, greater_than_equal_to, less_than_equal_to, condition, quote, values=[]) %} {{ config(severity = 'error') }} {% set condition = condition | default('') %} {% set date_column_name = date_column_name | default('closed_at') %} {% set greater_than_equal_to = greater_than_equal_to | default('2 day') %} {% set less_than_equal_to = less_than_equal_to | default('') %} + {% set quote = quote | default(false) %} + {% set values_string = [] %} + {% for value in values %} + {% do values_string.append("'" + value|string + "'") %} + {% endfor %} + {% set values_string = values_string | join(', ') %} {% set values = values | join(', ') %} - with all_values as ( select @@ -41,7 +46,11 @@ select value_field from all_values where value_field not in ( - {{ values }} + {% if quote %} + {{ values_string }} + {% else %} + {{ values }} + {% endif %} ) {% endtest %}