An 1220/gold blocks (#13)

* gold blocks

* fixes

* format

* test
This commit is contained in:
Jack Forgash 2022-05-16 16:22:34 -06:00 committed by GitHub
parent 6381b49a6a
commit 14dbded6a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 198 additions and 0 deletions

View File

@ -0,0 +1,15 @@
{{ config(
materialized = 'view'
) }}
WITH blocks AS (
SELECT
*
FROM
{{ ref('gold__blocks') }}
)
SELECT
*
FROM
blocks

View File

@ -0,0 +1,72 @@
version: 2
models:
- name: core__fact_blocks
description: Information about blocks on the FLOW network and corresponding metadata.
columns:
- name: block_height
description: "{{ doc('block_height') }}"
tests:
- not_null
- unique
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: block_timestamp
description: "{{ doc('block_timestamp') }}"
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 1
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ
- name: network
description: "{{ doc('network') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: chain_id
description: "{{ doc('chain_id') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: tx_count
description: "{{ doc('tx_count') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- name: id
description: "{{ doc('id') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: parent_id
description: "{{ doc('parent_id') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR

View File

@ -0,0 +1,35 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
cluster_by = ['block_timestamp::DATE'],
unique_key = 'block_height'
) }}
WITH silver_blocks AS (
SELECT
*
FROM
{{ ref('silver__blocks') }}
{% if is_incremental() %}
WHERE
_ingested_at :: DATE >= CURRENT_DATE - 2
{% endif %}
),
gold_blocks AS (
SELECT
block_height,
block_timestamp,
network,
chain_id,
tx_count,
id,
parent_id
FROM
silver_blocks
)
SELECT
*
FROM
gold_blocks

View File

@ -0,0 +1,72 @@
version: 2
models:
- name: gold__blocks
description: Information about blocks on the FLOW network and corresponding metadata.
columns:
- name: block_height
description: "{{ doc('block_height') }}"
tests:
- not_null
- unique
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- FLOAT
- name: block_timestamp
description: "{{ doc('block_timestamp') }}"
tests:
- not_null
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 1
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_NTZ
- name: network
description: "{{ doc('network') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: chain_id
description: "{{ doc('chain_id') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: tx_count
description: "{{ doc('tx_count') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- NUMBER
- name: id
description: "{{ doc('id') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR
- name: parent_id
description: "{{ doc('parent_id') }}"
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- STRING
- VARCHAR

View File

@ -4,6 +4,10 @@ version: 2
models:
- name: silver__blocks
description: Information about blocks on the FLOW network and corresponding metadata.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- block_height
columns:
- name: block_height