Skip to content

Commit

Permalink
Add raw application and category tables
Browse files Browse the repository at this point in the history
  • Loading branch information
horaceliuHL committed Dec 19, 2024
1 parent 68e9d90 commit 01be16e
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 15 deletions.
6 changes: 5 additions & 1 deletion models/dimensions/apps/dim_dune_namespaces.sql
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
select distinct namespace as namespace from {{ ref("dim_dune_contracts_post_sigma") }}
select
namespace,
max(last_updated) as last_updated
from {{ ref("dim_dune_contracts_post_sigma") }}
group by namespace
33 changes: 22 additions & 11 deletions models/dimensions/apps/dim_flipside_namespaces.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ with
namespace,
initcap(replace(replace(namespace, '-', ' '), '_', ' ')) as friendly_name,
max(category) as category,
max(sub_category) as sub_category
max(sub_category) as sub_category,
max(last_updated) as last_updated
from {{ ref("dim_flipside_contracts") }}
where chain = 'arbitrum' and namespace is not null
and category not in ('NFT', 'Token', 'ERC_1155')
Expand All @@ -19,7 +20,8 @@ with
namespace,
initcap(replace(replace(namespace, '-', ' '), '_', ' ')) as friendly_name,
max(category) as category,
max(sub_category) as sub_category
max(sub_category) as sub_category,
max(last_updated) as last_updated
from {{ ref("dim_flipside_contracts") }}
where chain = 'avalanche' and namespace is not null
and category not in ('NFT', 'Token', 'ERC_1155')
Expand All @@ -31,7 +33,8 @@ with
namespace,
initcap(replace(replace(namespace, '-', ' '), '_', ' ')) as friendly_name,
max(category) as category,
max(sub_category) as sub_category
max(sub_category) as sub_category,
max(last_updated) as last_updated
from {{ ref("dim_flipside_contracts") }}
where chain = 'base' and namespace is not null
and category not in ('NFT', 'Token', 'ERC_1155')
Expand All @@ -43,7 +46,8 @@ with
namespace,
initcap(replace(replace(namespace, '-', ' '), '_', ' ')) as friendly_name,
max(category) as category,
max(sub_category) as sub_category
max(sub_category) as sub_category,
max(last_updated) as last_updated
from {{ ref("dim_flipside_contracts") }}
where chain = 'bsc' and namespace is not null
and category not in ('NFT', 'Token', 'ERC_1155')
Expand All @@ -55,7 +59,8 @@ with
namespace,
initcap(replace(replace(namespace, '-', ' '), '_', ' ')) as friendly_name,
max(category) as category,
max(sub_category) as sub_category
max(sub_category) as sub_category,
max(last_updated) as last_updated
from {{ ref("dim_flipside_contracts") }}
where chain = 'ethereum' and namespace is not null
and category not in ('NFT', 'Token', 'ERC_1155')
Expand All @@ -67,7 +72,8 @@ with
namespace,
initcap(replace(replace(namespace, '-', ' '), '_', ' ')) as friendly_name,
max(category) as category,
max(sub_category) as sub_category
max(sub_category) as sub_category,
max(last_updated) as last_updated
from {{ ref("dim_flipside_contracts") }}
where chain = 'polygon' and namespace is not null
and category not in ('NFT', 'Token', 'ERC_1155')
Expand All @@ -79,7 +85,8 @@ with
namespace,
initcap(replace(replace(namespace, '-', ' '), '_', ' ')) as friendly_name,
max(category) as category,
max(sub_category) as sub_category
max(sub_category) as sub_category,
max(last_updated) as last_updated
from {{ ref("dim_flipside_contracts") }}
where chain = 'optimism' and namespace is not null
and category not in ('NFT', 'Token', 'ERC_1155')
Expand All @@ -91,7 +98,8 @@ with
namespace,
initcap(replace(replace(namespace, '-', ' '), '_', ' ')) as friendly_name,
max(category) as category,
max(sub_category) as sub_category
max(sub_category) as sub_category,
max(last_updated) as last_updated
from {{ ref("dim_flipside_contracts") }}
where chain = 'sei' and namespace is not null
group by namespace
Expand All @@ -102,7 +110,8 @@ with
namespace,
initcap(replace(replace(namespace, '-', ' '), '_', ' ')) as friendly_name,
max(category) as category,
max(sub_category) as sub_category
max(sub_category) as sub_category,
max(last_updated) as last_updated
from {{ ref("dim_flipside_contracts") }}
where chain = 'near' and namespace is not null
group by namespace
Expand All @@ -114,7 +123,8 @@ with
namespace,
initcap(replace(replace(namespace, '-', ' '), '_', ' ')) as friendly_name,
max(category) as category,
null as sub_category
null as sub_category,
max(last_updated) as last_updated
from {{ ref("dim_flipside_contracts") }}
where
chain = 'solana'
Expand All @@ -127,6 +137,7 @@ select
namespace,
coalesce(max_by(friendly_name, namespace), max(friendly_name)) as friendly_name,
coalesce(max_by(category, namespace), max(category)) as category,
coalesce(max_by(sub_category, namespace), max(sub_category)) as sub_category
coalesce(max_by(sub_category, namespace), max(sub_category)) as sub_category,
max(last_updated) as last_updated
from flipside_namespace
group by namespace
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ select
dune.address,
coalesce(sigma.override_namespace, dune.namespace) as namespace,
dune.name,
dune.chain
dune.chain,
dune.last_updated as last_updated
from {{ ref("dim_dune_contracts") }} as dune
left join
{{ source("SIGMA", "sigma_tagged_dune_contracts") }} as sigma
Expand Down
25 changes: 25 additions & 0 deletions models/dimensions/labeling/dim_all_apps_silver.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{
config(
materialized="incremental",
unique_key=["application", "source"],
incremental_strategy="merge",
)
}}

-- there are technically two more tables:
-- dim_new_apps_post_sigma and dim_apps_post_sigma
-- but they can be handled later
with unioned_table as (
SELECT namespace as application, 'dune' AS source, last_updated
FROM {{ ref("dim_dune_namespaces") }} where namespace is not null
UNION
SELECT namespace as application, 'sui' AS source, last_updated
FROM {{ ref("dim_sui_namespaces") }} where namespace is not null
UNION
SELECT namespace as application, 'flipside' AS source, last_updated
FROM {{ ref("dim_flipside_namespaces") }} where namespace is not null
)
select * from unioned_table
{% if is_incremental() %}
where last_updated > (SELECT MAX(last_updated) FROM {{ this }})
{% endif %}
22 changes: 22 additions & 0 deletions models/dimensions/labeling/dim_all_categores_silver.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{
config(
materialized="incremental",
unique_key=["category", "sub_category", "source"],
incremental_strategy="merge",
)
}}

-- there are technically two more tables:
-- dim_new_apps_post_sigma and dim_apps_post_sigma
-- but they can be handled later
with unioned_table as (
SELECT category, sub_category, 'sui' AS source, last_updated
FROM {{ ref("dim_sui_namespaces") }} where namespace is not null
UNION
SELECT category, sub_category, 'flipside' AS source, last_updated
FROM {{ ref("dim_flipside_namespaces") }} where namespace is not null
)
select * from unioned_table
{% if is_incremental() %}
where last_updated > (SELECT MAX(last_updated) FROM {{ this }})
{% endif %}
5 changes: 3 additions & 2 deletions models/staging/sui/dim_sui_namespaces.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ select
max(friendly_name) as friendly_name,
max(sub_category) as sub_category,
max(category) as category,
max(icon) as icon
from {{ ref("dim_sui_contracts") }} as sui_contracts
max(icon) as icon,
max(last_updated) as last_updated
from {{ ref("dim_sui_namespaces") }} as sui_contracts
group by namespace

0 comments on commit 01be16e

Please sign in to comment.