mirror of
https://github.com/FlipsideCrypto/kaia-models.git
synced 2026-02-06 13:26:45 +00:00
revert back to tables
This commit is contained in:
parent
2d4ab91901
commit
6f500085e3
@ -10,7 +10,7 @@
|
||||
|
||||
SELECT
|
||||
A.block_number AS block_number,
|
||||
{# HASH as block_hash, #} --new column name and order
|
||||
HASH as block_hash,
|
||||
block_timestamp,
|
||||
'mainnet' AS network,
|
||||
'kaia' AS blockchain,
|
||||
@ -20,7 +20,6 @@ SELECT
|
||||
extra_data,
|
||||
gas_limit,
|
||||
gas_used,
|
||||
hash,
|
||||
parent_hash,
|
||||
receipts_root,
|
||||
sha3_uncles,
|
||||
@ -66,6 +65,7 @@ SELECT
|
||||
'uncles',
|
||||
uncles
|
||||
) AS block_header_json, --deprecate
|
||||
hash, --deprecate
|
||||
blocks_id AS fact_blocks_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = "block_number",
|
||||
cluster_by = "block_timestamp::date",
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION",
|
||||
tags = ['non_realtime']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
@ -31,3 +34,12 @@ FROM
|
||||
'logs'
|
||||
) }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
@ -1,7 +1,10 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
materialized = 'incremental',
|
||||
unique_key = "block_number",
|
||||
incremental_strategy = 'delete+insert',
|
||||
cluster_by = "block_timestamp::date",
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION",
|
||||
tags = ['non_realtime']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
@ -17,7 +20,7 @@ SELECT
|
||||
tx_fee,
|
||||
tx_fee_precise,
|
||||
tx_status as tx_succeeded,
|
||||
tx_type,
|
||||
tx_type, --new column
|
||||
nonce,
|
||||
POSITION as tx_position,
|
||||
input_data,
|
||||
@ -33,9 +36,21 @@ SELECT
|
||||
v,
|
||||
transactions_id AS fact_transactions_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
modified_timestamp,
|
||||
block_hash, --deprecate
|
||||
POSITION --deprecate
|
||||
FROM
|
||||
{{ source(
|
||||
'klaytn_silver',
|
||||
'transactions'
|
||||
) }}
|
||||
) }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
@ -0,0 +1,9 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['full_test']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
@ -0,0 +1,19 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_gold__event_logs_full
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _LOG_ID
|
||||
- fsc_utils.sequence_gaps:
|
||||
partition_by:
|
||||
- BLOCK_NUMBER
|
||||
- TX_HASH
|
||||
column_name: EVENT_INDEX
|
||||
where: BLOCK_TIMESTAMP < CURRENT_DATE - 1
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
@ -0,0 +1,23 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['recent_test']
|
||||
) }}
|
||||
|
||||
WITH last_3_days AS (
|
||||
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
{{ ref("_block_lookback") }}
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
block_number >= (
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
last_3_days
|
||||
)
|
||||
@ -0,0 +1,18 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_gold__event_logs_recent
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _LOG_ID
|
||||
- fsc_utils.sequence_gaps:
|
||||
partition_by:
|
||||
- BLOCK_NUMBER
|
||||
- TX_HASH
|
||||
column_name: EVENT_INDEX
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: hour
|
||||
interval: 3
|
||||
@ -8,7 +8,7 @@ models:
|
||||
- fsc_utils.sequence_gaps:
|
||||
partition_by:
|
||||
- BLOCK_NUMBER
|
||||
column_name: TX_POSITION
|
||||
column_name: POSITION
|
||||
where: BLOCK_TIMESTAMP < CURRENT_DATE - 1
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
|
||||
@ -8,7 +8,7 @@ models:
|
||||
- fsc_utils.sequence_gaps:
|
||||
partition_by:
|
||||
- BLOCK_NUMBER
|
||||
column_name: TX_POSITION
|
||||
column_name: POSITION
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user