mirror of
https://github.com/FlipsideCrypto/ethereum-models.git
synced 2026-02-06 11:27:00 +00:00
AN-2699/snowflake-tags-ethereum (#357)
* added macros and updates to dbt_project/readme for snowflake tags * added database level tag * more tags * more tags * changed readme * added tags for chainlink and snapshot * more tags
This commit is contained in:
parent
e70a873699
commit
06dc0c4e35
42
README.md
42
README.md
@ -67,3 +67,45 @@ dbt run --var '{"UPDATE_UDFS_AND_SPS":True}' -m ...
|
||||
* Join the [chat](https://community.getdbt.com/) on Slack for live discussions and support
|
||||
* Find [dbt events](https://events.getdbt.com) near you
|
||||
* Check out [the blog](https://blog.getdbt.com/) for the latest news on dbt's development and best practices
|
||||
|
||||
## Applying Model Tags
|
||||
|
||||
### Database / Schema level tags
|
||||
|
||||
Database and schema tags are applied via the `add_database_or_schema_tags` macro. These tags are inherited by their downstream objects. To add/modify tags call the appropriate tag set function within the macro.
|
||||
|
||||
```
|
||||
{{ set_database_tag_value('SOME_DATABASE_TAG_KEY','SOME_DATABASE_TAG_VALUE') }}
|
||||
{{ set_schema_tag_value('SOME_SCHEMA_TAG_KEY','SOME_SCHEMA_TAG_VALUE') }}
|
||||
```
|
||||
|
||||
### Model tags
|
||||
|
||||
To add/update a model's snowflake tags, add/modify the `meta` model property under `config`. Only table level tags are supported at this time via DBT.
|
||||
|
||||
```
|
||||
{{ config(
|
||||
...,
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PURPOSE': 'SOME_PURPOSE'
|
||||
}
|
||||
}
|
||||
},
|
||||
...
|
||||
) }}
|
||||
```
|
||||
|
||||
By default, model tags are pushed to Snowflake on each load. You can disable this by setting the `UPDATE_SNOWFLAKE_TAGS` project variable to `False` during a run.
|
||||
|
||||
```
|
||||
dbt run --var '{"UPDATE_SNOWFLAKE_TAGS":False}' -s models/core/core__fact_blocks.sql
|
||||
```
|
||||
|
||||
### Querying for existing tags on a model in snowflake
|
||||
|
||||
```
|
||||
select *
|
||||
from table(ethereum.information_schema.tag_references('ethereum.core.fact_blocks', 'table'));
|
||||
```
|
||||
@ -37,6 +37,9 @@ on-run-start:
|
||||
- "{{ sp_create_cross_db_share_clones() }}"
|
||||
- "{{ create_udfs() }}"
|
||||
|
||||
on-run-end:
|
||||
- '{{ apply_meta_as_tags(results) }}'
|
||||
|
||||
# Configuring models
|
||||
# Full documentation: https://docs.getdbt.com/docs/configuring-models
|
||||
|
||||
@ -49,3 +52,4 @@ vars:
|
||||
STREAMLINE_INVOKE_STREAMS: False
|
||||
STREAMLINE_USE_DEV_FOR_EXTERNAL_TABLES: False
|
||||
UPDATE_UDFS_AND_SPS: False
|
||||
UPDATE_SNOWFLAKE_TAGS: True
|
||||
|
||||
4
macros/tags/add_database_or_schema_tags.sql
Normal file
4
macros/tags/add_database_or_schema_tags.sql
Normal file
@ -0,0 +1,4 @@
|
||||
{% macro add_database_or_schema_tags() %}
|
||||
{{ set_database_tag_value('BLOCKCHAIN_NAME','ETHEREUM') }}
|
||||
{{ set_database_tag_value('BLOCKCHAIN_TYPE','EVM') }}
|
||||
{% endmacro %}
|
||||
127
macros/tags/snowflake_tagging.sql
Normal file
127
macros/tags/snowflake_tagging.sql
Normal file
@ -0,0 +1,127 @@
|
||||
{% macro apply_meta_as_tags(results) %}
|
||||
{% if var("UPDATE_SNOWFLAKE_TAGS") %}
|
||||
{{ log('apply_meta_as_tags', info=False) }}
|
||||
{{ log(results, info=False) }}
|
||||
{% if execute %}
|
||||
|
||||
{%- set tags_by_schema = {} -%}
|
||||
{% for res in results -%}
|
||||
{% if res.node.meta.database_tags %}
|
||||
|
||||
{%- set model_database = res.node.database -%}
|
||||
{%- set model_schema = res.node.schema -%}
|
||||
{%- set model_schema_full = model_database+'.'+model_schema -%}
|
||||
{%- set model_alias = res.node.alias -%}
|
||||
|
||||
{% if model_schema_full not in tags_by_schema.keys() %}
|
||||
{{ log('need to fetch tags for schema '+model_schema_full, info=False) }}
|
||||
{%- call statement('main', fetch_result=True) -%}
|
||||
show tags in {{model_database}}.{{model_schema}}
|
||||
{%- endcall -%}
|
||||
{%- set _ = tags_by_schema.update({model_schema_full: load_result('main')['table'].columns.get('name').values()|list}) -%}
|
||||
{{ log('Added tags to cache', info=False) }}
|
||||
{% else %}
|
||||
{{ log('already have tag info for schema', info=False) }}
|
||||
{% endif %}
|
||||
|
||||
{%- set current_tags_in_schema = tags_by_schema[model_schema_full] -%}
|
||||
{{ log('current_tags_in_schema:', info=False) }}
|
||||
{{ log(current_tags_in_schema, info=False) }}
|
||||
{{ log("========== Processing tags for "+model_schema_full+"."+model_alias+" ==========", info=False) }}
|
||||
|
||||
{% set line -%}
|
||||
node: {{ res.node.unique_id }}; status: {{ res.status }} (message: {{ res.message }})
|
||||
node full: {{ res.node}}
|
||||
meta: {{ res.node.meta}}
|
||||
materialized: {{ res.node.config.materialized }}
|
||||
{%- endset %}
|
||||
{{ log(line, info=False) }}
|
||||
|
||||
{%- call statement('main', fetch_result=True) -%}
|
||||
select LEVEL,UPPER(TAG_NAME) as TAG_NAME,TAG_VALUE from table(information_schema.tag_references_all_columns('{{model_schema}}.{{model_alias}}', 'table'))
|
||||
{%- endcall -%}
|
||||
{%- set existing_tags_for_table = load_result('main')['data'] -%}
|
||||
{{ log('Existing tags for table:', info=False) }}
|
||||
{{ log(existing_tags_for_table, info=False) }}
|
||||
|
||||
{{ log('--', info=False) }}
|
||||
{% for table_tag in res.node.meta.database_tags.table %}
|
||||
|
||||
{{ create_tag_if_missing(current_tags_in_schema,table_tag|upper) }}
|
||||
{% set desired_tag_value = res.node.meta.database_tags.table[table_tag] %}
|
||||
|
||||
{{set_table_tag_value_if_different(model_schema,model_alias,table_tag,desired_tag_value,existing_tags_for_table)}}
|
||||
{% endfor %}
|
||||
{{ log("========== Finished processing tags for "+model_alias+" ==========", info=False) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro create_tag_if_missing(all_tag_names,table_tag) %}
|
||||
{% if table_tag not in all_tag_names %}
|
||||
{{ log('Creating missing tag '+table_tag, info=False) }}
|
||||
{%- call statement('main', fetch_result=True) -%}
|
||||
create tag if not exists silver.{{table_tag}}
|
||||
{%- endcall -%}
|
||||
{{ log(load_result('main').data, info=False) }}
|
||||
{% else %}
|
||||
{{ log('Tag already exists: '+table_tag, info=False) }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro set_table_tag_value_if_different(model_schema,table_name,tag_name,desired_tag_value,existing_tags) %}
|
||||
{{ log('Ensuring tag '+tag_name+' has value '+desired_tag_value+' at table level', info=False) }}
|
||||
{%- set existing_tag_for_table = existing_tags|selectattr('0','equalto','TABLE')|selectattr('1','equalto',tag_name|upper)|list -%}
|
||||
{{ log('Filtered tags for table:', info=False) }}
|
||||
{{ log(existing_tag_for_table[0], info=False) }}
|
||||
{% if existing_tag_for_table|length > 0 and existing_tag_for_table[0][2]==desired_tag_value %}
|
||||
{{ log('Correct tag value already exists', info=False) }}
|
||||
{% else %}
|
||||
{{ log('Setting tag value for '+tag_name+' to value '+desired_tag_value, info=False) }}
|
||||
{%- call statement('main', fetch_result=True) -%}
|
||||
alter table {{model_schema}}.{{table_name}} set tag {{tag_name}} = '{{desired_tag_value}}'
|
||||
{%- endcall -%}
|
||||
{{ log(load_result('main').data, info=False) }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro set_column_tag_value_if_different(table_name,column_name,tag_name,desired_tag_value,existing_tags) %}
|
||||
{{ log('Ensuring tag '+tag_name+' has value '+desired_tag_value+' at column level', info=False) }}
|
||||
{%- set existing_tag_for_column = existing_tags|selectattr('0','equalto','COLUMN')|selectattr('1','equalto',tag_name|upper)|list -%}
|
||||
{{ log('Filtered tags for column:', info=False) }}
|
||||
{{ log(existing_tag_for_column[0], info=False) }}
|
||||
{% if existing_tag_for_column|length > 0 and existing_tag_for_column[0][2]==desired_tag_value %}
|
||||
{{ log('Correct tag value already exists', info=False) }}
|
||||
{% else %}
|
||||
{{ log('Setting tag value for '+tag_name+' to value '+desired_tag_value, info=False) }}
|
||||
{%- call statement('main', fetch_result=True) -%}
|
||||
alter table {{table_name}} modify column {{column_name}} set tag {{tag_name}} = '{{desired_tag_value}}'
|
||||
{%- endcall -%}
|
||||
{{ log(load_result('main').data, info=False) }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro set_database_tag_value(tag_name,tag_value) %}
|
||||
{% set query %}
|
||||
create tag if not exists silver.{{tag_name}}
|
||||
{% endset %}
|
||||
{% do run_query(query) %}
|
||||
{% set query %}
|
||||
alter database {{target.database}} set tag {{target.database}}.silver.{{tag_name}} = '{{tag_value}}'
|
||||
{% endset %}
|
||||
{% do run_query(query) %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro set_schema_tag_value(target_schema,tag_name,tag_value) %}
|
||||
{% set query %}
|
||||
create tag if not exists silver.{{tag_name}}
|
||||
{% endset %}
|
||||
{% do run_query(query) %}
|
||||
{% set query %}
|
||||
alter schema {{target.database}}.{{target_schema}} set tag {{target.database}}.silver.{{tag_name}} = '{{tag_value}}'
|
||||
{% endset %}
|
||||
{% do run_query(query) %}
|
||||
{% endmacro %}
|
||||
@ -1,5 +1,13 @@
|
||||
{{ config(
|
||||
materialized = 'table',
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'SUSHI',
|
||||
'PURPOSE': 'DEFI, DEX'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
select merkle_root,
|
||||
|
||||
@ -4,7 +4,15 @@
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE']
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'SUSHI',
|
||||
'PURPOSE': 'DEFI, DEX'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH borrow_txns AS (
|
||||
|
||||
@ -4,7 +4,15 @@
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE']
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'SUSHI',
|
||||
'PURPOSE': 'DEFI, DEX'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH lending_txns AS (
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'SUSHI',
|
||||
'PURPOSE': 'DEFI, DEX, SWAPS'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'incremental',
|
||||
unique_key = "_log_id",
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_borrows', 'address_labels']
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_borrows', 'address_labels'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'AAVE',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH --borrows from Aave LendingPool contracts
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'incremental',
|
||||
unique_key = "_log_id",
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_deposits', 'address_labels']
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_deposits', 'address_labels'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'AAVE',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH deposits AS(
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'incremental',
|
||||
unique_key = "_log_id",
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_flashloans', 'address_labels']
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_flashloans', 'address_labels'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'AAVE',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH flashloan AS (
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'incremental',
|
||||
unique_key = "_log_id",
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_liquidations', 'address_labels']
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_liquidations', 'address_labels'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'AAVE',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH liquidation AS(
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'incremental',
|
||||
unique_key = "read_id",
|
||||
incremental_strategy = 'delete+insert',
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_market_stats', 'address_labels']
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_market_stats', 'address_labels'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'AAVE',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH blocks AS (
|
||||
|
||||
@ -4,7 +4,15 @@
|
||||
sort='block_number',
|
||||
unique_key= "CONCAT_WS('-', proposal_tx, proposal_id)",
|
||||
incremental_strategy='delete+insert',
|
||||
tags=['snowflake', 'ethereum', 'aave', 'aave_proposals']
|
||||
tags=['snowflake', 'ethereum', 'aave', 'aave_proposals'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'AAVE',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}}
|
||||
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'incremental',
|
||||
unique_key = "_log_id",
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_repayments', 'address_labels']
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_repayments', 'address_labels'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'AAVE',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH repay AS(
|
||||
|
||||
@ -3,7 +3,15 @@
|
||||
sort = 'block_number',
|
||||
unique_key = "_log_id",
|
||||
incremental_strategy = 'delete+insert',
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_votes']
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_votes'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'AAVE',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH base AS (
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'incremental',
|
||||
unique_key = "_log_id",
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_withdraws', 'address_labels']
|
||||
tags = ['snowflake', 'ethereum', 'aave', 'aave_withdraws', 'address_labels'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'AAVE',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH withdraw AS(
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'CHAINLINK',
|
||||
'PURPOSE': 'ORACLE'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'CHAINLINK',
|
||||
'PURPOSE': 'ORACLE'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'CHAINLINK',
|
||||
'PURPOSE': 'ORACLE'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
tags = ['compound']
|
||||
tags = ['compound'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'COMPOUND',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
-- Pulls contract details for relevant c assets. The case when handles cETH.
|
||||
WITH base AS (
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'incremental',
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['compound']
|
||||
tags = ['compound'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'COMPOUND',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
-- pull all ctoken addresses and corresponding name
|
||||
WITH asset_details AS (
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'incremental',
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['compound']
|
||||
tags = ['compound'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'COMPOUND',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
-- pull all ctoken addresses and corresponding name
|
||||
WITH asset_details AS (
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'incremental',
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['compound']
|
||||
tags = ['compound'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'COMPOUND',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
-- pull all ctoken addresses and corresponding name
|
||||
-- add the collateral liquidated here
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'COMPOUND',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
-- pull all ctoken addresses and corresponding name
|
||||
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'incremental',
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['compound']
|
||||
tags = ['compound'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'COMPOUND',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
-- pull all ctoken addresses and corresponding name
|
||||
WITH asset_details AS (
|
||||
|
||||
@ -2,7 +2,15 @@
|
||||
materialized = 'incremental',
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['compound']
|
||||
tags = ['compound'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'COMPOUND',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
-- pull all ctoken addresses and corresponding name
|
||||
WITH asset_details AS (
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PURPOSE': 'NFT'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -2,7 +2,14 @@
|
||||
materialized = 'view',
|
||||
tags = ['balances'],
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PURPOSE': 'BALANCES'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH prices AS (
|
||||
|
||||
@ -2,7 +2,14 @@
|
||||
materialized = 'view',
|
||||
tags = ['balances'],
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PURPOSE': 'BALANCES'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH prices AS (
|
||||
|
||||
@ -4,7 +4,14 @@
|
||||
"columns": true },
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
post_hook = "{{ grant_data_share_statement('EZ_NFT_MINTS', 'TABLE') }}"
|
||||
post_hook = "{{ grant_data_share_statement('EZ_NFT_MINTS', 'TABLE') }}",
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PURPOSE': 'NFT'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH nft_mints AS (
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PURPOSE': 'NFT'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -2,7 +2,14 @@
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
tags = ['core']
|
||||
tags = ['core'],
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PURPOSE': 'NFT'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'SNAPSHOT',
|
||||
'PURPOSE': 'GOVERNANCE'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PURPOSE': 'BALANCES'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PURPOSE': 'BALANCES'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'SUSHI, UNISWAP, CURVE, SYNTHETIX, BALANCER'
|
||||
'PURPOSE': 'DEX, SWAPS'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
WITH v2_swaps AS (
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
materialized = 'view',
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'MAKER, MKR',
|
||||
'PURPOSE': 'GOVERNANCE, DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
materialized = 'view',
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'MAKER, MKR',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
materialized = 'view',
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'MAKER, MKR',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
materialized = 'view',
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'MAKER, MKR',
|
||||
'PURPOSE': 'GOVERNANCE, DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
materialized = 'view',
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'MAKER, MKR',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
materialized = 'view',
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'MAKER, MKR',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
materialized = 'view',
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'MAKER, MKR',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
materialized = 'view',
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'MAKER, MKR',
|
||||
'PURPOSE': 'DEFI'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'UNISWAPV3',
|
||||
'PURPOSE': 'DEFI, DEX'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'UNISWAPV3',
|
||||
'PURPOSE': 'DEFI, DEX'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'UNISWAPV3',
|
||||
'PURPOSE': 'DEFI, DEX'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'UNISWAPV3',
|
||||
'PURPOSE': 'DEFI, DEX'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'UNISWAPV3',
|
||||
'PURPOSE': 'DEFI, DEX'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true }
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'UNISWAPV3',
|
||||
'PURPOSE': 'DEFI, DEX, SWAPS'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
|
||||
Loading…
Reference in New Issue
Block a user