macros and bronze

This commit is contained in:
forgash_ 2022-07-12 12:55:52 -06:00
parent 2b8183f234
commit e3f8483041
5 changed files with 67 additions and 0 deletions

View File

@ -24,6 +24,9 @@ clean-targets: # directories to be removed by `dbt clean`
- "dbt_modules"
- "dbt_packages"
on-run-start:
- "{{create_sps()}}"
# Configuring models
# Full documentation: https://docs.getdbt.com/docs/configuring-models

6
macros/create_sps.sql Normal file
View File

@ -0,0 +1,6 @@
{% macro create_sps() %}
{% if target.database == 'NEAR' %}
CREATE schema IF NOT EXISTS _internal;
{{ sp_create_prod_clone('_internal') }};
{% endif %}
{% endmacro %}

View File

@ -0,0 +1,17 @@
{% macro generate_schema_name(
custom_schema_name = none,
node = none
) -%}
{% set node_name = node.name %}
{% set split_name = node_name.split('__') %}
{{ split_name [0] | trim }}
{%- endmacro %}
{% macro generate_alias_name(
custom_alias_name = none,
node = none
) -%}
{% set node_name = node.name %}
{% set split_name = node_name.split('__') %}
{{ split_name [1] | trim }}
{%- endmacro %}

View File

@ -0,0 +1,20 @@
{{ config (
materialized = 'view'
) }}
SELECT
record_id,
offset_id,
block_id,
block_timestamp,
network,
chain_id,
tx_count,
header,
ingested_at AS _ingested_at,
_inserted_timestamp
FROM
{{ source(
"chainwalkers",
"near_blocks"
) }}

View File

@ -0,0 +1,21 @@
{{ config (
materialized = 'view'
) }}
SELECT
record_id,
tx_id,
tx_block_index,
offset_id,
block_id,
block_timestamp,
network,
chain_id,
tx,
ingested_at AS _ingested_at,
_inserted_timestamp
FROM
{{ source(
"chainwalkers",
"near_blocks"
) }}