Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPE-201 Remove dunesql tag + dunesql tag selectors #4663

Merged
merged 12 commits into from
Oct 24, 2023
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/commit_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: "./scripts/ensure_cluster.sh"

- name: dbt compile to create prod manifest from main
run: "dbt compile --target-path . $PROFILE --select tag:dunesql"
run: "dbt compile --target-path . $PROFILE"

- name: copy old manifest locally
run: "aws s3 cp s3://manifest-spellbook-dunesql/manifest.json s3://manifest-spellbook-dunesql/previous_manifest.json"
Expand Down
19 changes: 7 additions & 12 deletions .github/workflows/dbt_slim_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,30 @@ jobs:
run: "./scripts/ensure_cluster.sh"

- name: dbt compile to create manifest to compare to
run: "dbt compile $PROFILE --select tag:dunesql"
run: "dbt compile $PROFILE"

- name: check schemas
run: |
test=$(dbt --quiet --no-print ls $PROFILE --resource-type model --select state:modified,config.schema:no_schema --output path --state .)
[[ -z "$test" ]] && { echo "Success: All models have a custom schema"; exit 0; } || { echo "Found models without custom schema:"; echo "$test"; exit 1; }

- name: check tags
run: |
test=$(dbt --quiet --no-print ls $PROFILE --resource-type model --select state:modified --exclude tag:legacy tag:dunesql --output path --state .)
[[ -z "$test" ]] && { echo "Success: No models without a tag"; exit 0; } || { echo "Found models with no dunesql or legacy tag:"; echo "$test"; exit 1; }

- name: dbt seed
run: "dbt seed $PROFILE --select state:modified,tag:dunesql --exclude tag:prod_exclude tag:remove --state ."
run: "dbt seed $PROFILE --select state:modified --exclude tag:prod_exclude tag:remove --state ."

- name: dbt run initial model(s)
run: "dbt -x run $PROFILE --select state:modified,tag:dunesql --exclude tag:prod_exclude tag:remove --defer --state ."
run: "dbt -x run $PROFILE --select state:modified --exclude tag:prod_exclude tag:remove --defer --state ."

- name: dbt test initial model(s)
run: "dbt test $PROFILE --select state:new,tag:dunesql state:modified,tag:dunesql --exclude tag:prod_exclude tag:remove --defer --state ."
run: "dbt test $PROFILE --select state:new state:modified --exclude tag:prod_exclude tag:remove --defer --state ."

- name: Set environment variable for incremental model count
run: |
echo "INC_MODEL_COUNT=$(echo dbt ls $PROFILE --select state:modified,config.materialized:incremental,tag:dunesql --state . --resource-type model | wc -l)" >> $GITHUB_ENV
echo "INC_MODEL_COUNT=$(echo dbt ls $PROFILE --select state:modified,config.materialized:incremental --state . --resource-type model | wc -l)" >> $GITHUB_ENV

- name: dbt run incremental model(s) if applicable
if: env.INC_MODEL_COUNT > 0
run: "dbt run $PROFILE --select state:modified,config.materialized:incremental,tag:dunesql --exclude tag:prod_exclude tag:remove --defer --state ."
run: "dbt run $PROFILE --select state:modified,config.materialized:incremental --exclude tag:prod_exclude tag:remove --defer --state ."

- name: dbt test incremental model(s) if applicable
if: env.INC_MODEL_COUNT > 0
run: "dbt test $PROFILE --select state:modified,config.materialized:incremental,tag:dunesql --exclude tag:prod_exclude tag:remove --defer --state ."
run: "dbt test $PROFILE --select state:modified,config.materialized:incremental --exclude tag:prod_exclude tag:remove --defer --state ."
10 changes: 0 additions & 10 deletions macros/dune/alias.sql

This file was deleted.

6 changes: 1 addition & 5 deletions macros/dune/macros_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,4 @@ macros:

- name: source
description: >
Change source database.

- name: alias
description: >
Add dummy alias
Change source database.
43 changes: 15 additions & 28 deletions macros/expose_spells.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,22 @@
{%- do exceptions.raise_compiler_error("Invalid contributors '%s'. The list of contributors must be valid JSON." % contributors) -%}
{%- endif -%}
{%- if target.name == 'prod' -%}
{%- if 'dunesql' not in model.config.get("tags") -%}
ALTER {{"view" if model.config.materialized == "view" else "table"}} {{ this }}
SET TBLPROPERTIES (
'dune.public'='true',
'dune.data_explorer.blockchains'= '{{ blockchains }}', -- e.g., ["ethereum","solana"]
'dune.data_explorer.category'='abstraction',
'dune.data_explorer.abstraction.type'= '{{ spell_type }}', -- 'project' or 'sector'
'dune.data_explorer.abstraction.name'= '{{ spell_name }}', -- 'aave' or 'uniswap'
'dune.data_explorer.contributors'= '{{ validated_contributors }}', -- e.g., ["soispoke","jeff_dude"]
'dune.vacuum' = '{"enabled":true}'
)
{%- set properties = {
'dune.public': 'true',
'dune.data_explorer.blockchains': blockchains | as_text,
'dune.data_explorer.category': 'abstraction',
'dune.data_explorer.abstraction.type': spell_type,
'dune.data_explorer.abstraction.name': spell_name,
'dune.data_explorer.contributors': validated_contributors,
'dune.vacuum': '{"enabled":true}'
} -%}
{%- if model.config.materialized == "view" -%}
CALL {{ model.database }}._internal.alter_view_properties('{{ model.schema }}', '{{ model.alias }}',
{{ trino_properties(properties) }}
)
{%- else -%}
{%- set properties = {
'dune.public': 'true',
'dune.data_explorer.blockchains': blockchains | as_text,
'dune.data_explorer.category': 'abstraction',
'dune.data_explorer.abstraction.type': spell_type,
'dune.data_explorer.abstraction.name': spell_name,
'dune.data_explorer.contributors': validated_contributors,
'dune.vacuum': '{"enabled":true}'
} -%}
{%- if model.config.materialized == "view" -%}
CALL {{ model.database }}._internal.alter_view_properties('{{ model.schema }}', '{{ model.alias }}',
{{ trino_properties(properties) }}
)
{%- else -%}
ALTER TABLE {{ this }}
SET PROPERTIES extra_properties = {{ trino_properties(properties) }}
{%- endif -%}
ALTER TABLE {{ this }}
SET PROPERTIES extra_properties = {{ trino_properties(properties) }}
{%- endif -%}
{%- endif -%}
{%- endmacro -%}
Expand Down
19 changes: 6 additions & 13 deletions macros/mark_as_spell.sql
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
{% macro mark_as_spell(this, materialization) %}
{%- if target.name == 'prod' -%}
{%- if 'dunesql' not in model.config.get("tags") -%}
ALTER {{"view" if materialization == "view" else "table"}} {{ this }}
SET TBLPROPERTIES (
'dune.data_explorer.category'='abstraction'
{%- set properties = { 'dune.data_explorer.category': 'abstraction' } -%}
{%- if model.config.materialized == "view" -%}
CALL {{ model.database }}._internal.alter_view_properties('{{ model.schema }}', '{{ model.alias }}',
{{ trino_properties(properties) }}
)
{%- else -%}
{%- set properties = { 'dune.data_explorer.category': 'abstraction' } -%}
{%- if model.config.materialized == "view" -%}
CALL {{ model.database }}._internal.alter_view_properties('{{ model.schema }}', '{{ model.alias }}',
{{ trino_properties(properties) }}
)
{%- else -%}
ALTER TABLE {{ this }}
SET PROPERTIES extra_properties = {{ trino_properties(properties) }}
{%- endif -%}
ALTER TABLE {{ this }}
SET PROPERTIES extra_properties = {{ trino_properties(properties) }}
{%- endif -%}
{%- endif -%}
{%- endmacro -%}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{config(
tags= ['dunesql'],

schema = 'nft_arbitrum',
alias=alias('aggregators')
alias='aggregators'
)}}

SELECT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{config(
tags = ['dunesql'],

schema = 'nft_avalanche_c',
alias=alias('aggregators')
alias='aggregators'
)
}}
SELECT
Expand Down
4 changes: 2 additions & 2 deletions models/_sector/nft/aggregators/chains/nft_bnb_aggregators.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{config(
tags = ['dunesql'],

schema = 'nft_bnb',
alias = alias('aggregators')
alias = 'aggregators'
)}}

SELECT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_celo',
alias = alias('aggregators'),
alias = 'aggregators',
post_hook='{{ expose_spells(\'["celo"]\',
"sector",
"nft",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{config(
tags = ['dunesql'],

schema = 'nft_ethereum',
alias=alias('aggregators'),
alias='aggregators',
materialized='table',
file_format = 'delta'
)}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{config(
tags = ['dunesql'],

schema = 'nft_ethereum',
alias = alias('aggregators_gem')
alias = 'aggregators_gem'
)}}
WITH vasa_contracts as (
SELECT distinct
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{config(
tags = ['dunesql'],

schema = 'nft_ethereum',
alias=alias('aggregators_manual')
alias='aggregators_manual'
)}}
SELECT
contract_address,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
tags = ['dunesql'],

schema = 'nft_ethereum',
alias = alias('aggregators_markers'),
alias = 'aggregators_markers',
materialized = 'table',
unique_key='hash_marker',
post_hook='{{ expose_spells(\'["ethereum"]\',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{config(
tags = ['dunesql'],

schema = 'nft_optimism',
alias = alias('aggregators')
alias = 'aggregators'
)}}

SELECT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{config(
tags = ['dunesql'],

schema = 'nft_polygon',
alias = alias('aggregators')
alias = 'aggregators'
)}}

SELECT
Expand Down
4 changes: 2 additions & 2 deletions models/_sector/nft/aggregators/nft_aggregators.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
tags = ['dunesql'],

schema = 'nft',
alias = alias('aggregators'),
alias = 'aggregators',
post_hook='{{ expose_spells(\'["avalanche_c","bnb","ethereum","polygon","optimism","celo"]\',
"sector",
"nft",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_arbitrum',
alias = alias('approvals'),
alias = 'approvals',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_avalanche_c',
alias = alias('approvals'),
alias = 'approvals',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down
4 changes: 2 additions & 2 deletions models/_sector/nft/approvals/chains/nft_base_approvals.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_base',
alias = alias('approvals'),
alias = 'approvals',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down
4 changes: 2 additions & 2 deletions models/_sector/nft/approvals/chains/nft_bnb_approvals.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_bnb',
alias = alias('approvals'),
alias = 'approvals',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down
4 changes: 2 additions & 2 deletions models/_sector/nft/approvals/chains/nft_celo_approvals.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_celo',
alias = alias('approvals'),
alias = 'approvals',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_ethereum',
alias = alias('approvals'),
alias = 'approvals',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down
4 changes: 2 additions & 2 deletions models/_sector/nft/approvals/chains/nft_fantom_approvals.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_fantom',
alias = alias('approvals'),
alias = 'approvals',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down
4 changes: 2 additions & 2 deletions models/_sector/nft/approvals/chains/nft_gnosis_approvals.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_gnosis',
alias = alias('approvals'),
alias = 'approvals',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down
4 changes: 2 additions & 2 deletions models/_sector/nft/approvals/chains/nft_goerli_approvals.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_goerli',
alias = alias('approvals'),
alias = 'approvals',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_optimism',
alias = alias('approvals'),
alias = 'approvals',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down
4 changes: 2 additions & 2 deletions models/_sector/nft/approvals/chains/nft_polygon_approvals.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_polygon',
alias = alias('approvals'),
alias = 'approvals',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down
4 changes: 2 additions & 2 deletions models/_sector/nft/approvals/chains/nft_zksync_approvals.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{
config(
tags = ['dunesql'],

schema = 'nft_zksync',
alias = alias('approvals'),
alias = 'approvals',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down
Loading
Loading