fix:macros test

This commit is contained in:
WHYTEWYLL 2023-07-05 15:14:02 +02:00
parent 0870c1cb2c
commit 1880f4e213
15 changed files with 99 additions and 41 deletions

View File

@ -1,37 +1,34 @@
{% macro sequence_gaps(
table,
partition_by,
column
) %}
{%- set partition_sql = partition_by | join(", ") -%}
{%- set previous_column = "prev_" ~ column -%}
WITH source AS (
SELECT
{{ partition_sql + "," if partition_sql }}
{{ column }},
LAG(
{{ column }},
1
) over (
{{ "PARTITION BY " ~ partition_sql if partition_sql }}
ORDER BY
{{ column }} ASC
) AS {{ previous_column }}
FROM
{{ table }}
WHERE
block_timestamp::date <= current_date - 1
)
{% test sequence_gaps(
model,
partition_by,
column_name
) %}
{%- set partition_sql = partition_by | join(", ") -%}
{%- set previous_column = "prev_" ~ column_name -%}
WITH source AS (
SELECT
{{ partition_sql + "," if partition_sql }}
{{ column_name }},
LAG(
{{ column_name }},
1
) over (
{{ "PARTITION BY " ~ partition_sql if partition_sql }}
ORDER BY
{{ column_name }} ASC
) AS {{ previous_column }}
FROM
{{ model }}
)
SELECT
{{ partition_sql + "," if partition_sql }}
{{ previous_column }},
{{ column }},
{{ column }} - {{ previous_column }}
{{ column_name }},
{{ column_name }} - {{ previous_column }}
- 1 AS gap
FROM
source
WHERE
{{ column }} - {{ previous_column }} <> 1
{{ column_name }} - {{ previous_column }} <> 1
ORDER BY
gap DESC
{% endmacro %}
gap DESC {% endtest %}

View File

@ -0,0 +1,14 @@
{% test tx_block_count(
model,
column_name
) %}
SELECT
{{ column_name }},
COUNT(DISTINCT block_number) AS num_blocks
FROM
{{ model }}
GROUP BY {{ column_name }}
HAVING num_blocks > 1
{% endtest %}

View File

@ -1,4 +1,4 @@
{% macro tx_gaps(
{% test tx_gaps(
model
) %}
WITH block_base AS (
@ -30,4 +30,4 @@ FROM
ON block_base.block_id = model_name.block_id
WHERE
tx_count <> model_tx_count
{% endmacro %}
{% endtest %}

View File

@ -0,0 +1,5 @@
{% docs logs_contract_address %}
The address interacted with for a given event.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs event_index %}
Event number within a transaction.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs event_removed %}
Whether the event has been removed from the transaction.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs id_events %}
This is the primary key for this table. This is a concatenation of the transaction hash and the event index at which the event occurred.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs logs_data %}
The un-decoded event data.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs logs_table_doc %}
This table contains log level data for the Aurora Blockchain. This table can be used to analyze trends at a log level, for example gas fees vs. total transactions over time. For more information, please see Aurora scan Resources.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs nft_origin_sig %}
The function signature of this transaction.
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs topics %}
The un-decoded event input topics.
{% enddocs %}

View File

@ -0,0 +1,11 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
tags = ['core']
) }}
SELECT
*
FROM
{{ ref('silver__relevant_contracts') }}

View File

@ -1,6 +1,6 @@
version: 2
models:
- name: core__fact_event_logs
- name: core__fact_logs
description: '{{ doc("logs_table_doc") }}'
columns:
@ -9,7 +9,7 @@ models:
- name: BLOCK_TIMESTAMP
description: '{{ doc("block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("logs_tx_hash") }}'
description: '{{ doc("tx_hash") }}'
- name: EVENT_INDEX
description: '{{ doc("event_index") }}'
- name: CONTRACT_ADDRESS
@ -21,12 +21,12 @@ models:
- name: EVENT_REMOVED
description: '{{ doc("event_removed") }}'
- name: _LOG_ID
description: '{{ doc("log_id_events") }}'
description: '{{ doc("id_events") }}'
- name: TX_STATUS
description: '{{ doc("tx_status") }}'
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("nft_origin_sig") }}'
- name: ORIGIN_FROM_ADDRESS
description: '{{ doc("origin_from") }}'
description: "The from address at the transaction level."
- name: ORIGIN_TO_ADDRESS
description: '{{ doc("origin_to") }}'
description: "The to address at the transaction level."

View File

@ -5,7 +5,7 @@
SELECT
contract_address,
'ethereum' AS blockchain,
'Aurora' AS blockchain,
COUNT(*) AS events,
MAX(block_number) AS latest_block
FROM

View File

@ -108,10 +108,6 @@ models:
column_type_list:
- NUMBER
- FLOAT
- name: EFFECTIVE_GAS_PRICE
tests:
- not_null:
where: NOT IS_PENDING
- name: ORIGIN_FUNCTION_SIGNATURE
tests:
- not_null