Skip to content

Commit

Permalink
is deleted updates (#133)
Browse files Browse the repository at this point in the history
* is deleted updates

* fix
  • Loading branch information
austinFlipside authored Jan 30, 2024
1 parent 350ea72 commit b51da57
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
9 changes: 6 additions & 3 deletions models/bronze/labels/bronze__labels.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ SELECT
label_type,
label_subtype,
address_name,
project_name
project_name,
_is_deleted,
modified_timestamp,
labels_combined_id
FROM
{{ source(
'crosschain',
'dim_labels'
'silver_crosschain',
'labels_combined'
) }}
WHERE
blockchain = 'base'
Expand Down
5 changes: 5 additions & 0 deletions models/doc_descriptions/labels/table_dim_labels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% docs table_dim_labels %}

The labels table is a store of one-to-one address identifiers, or an address name. Labels are broken out into a "type" (such as cex, dex, dapp, games, etc.) and a "subtype" (ex: contract_deployer, hot_wallet, token_contract, etc.) in order to help classify each address name into similar groups. Our labels are sourced from many different places, but can primarily be grouped into two categories: automatic and manual. Automatic labels are continuously labeled based on certain criteria, such as a known contract deploying another contract, behavior based algorithms for finding deposit wallets, and consistent data pulls of custom protocol APIs. Manual labels are done periodically to find addresses that cannot be found programmatically such as finding new protocol addresses, centralized exchange hot wallets, or trending addresses. Labels can also be added by our community by using our add-a-label tool (https://science.flipsidecrypto.xyz/add-a-label/) or on-chain with near (https://near.social/lord1.near/widget/Form) and are reviewed by our labels team. A label can be removed by our labels team if it is found to be incorrect or no longer relevant; this generally will only happen for mislabeled deposit wallets.

{% enddocs %}
17 changes: 3 additions & 14 deletions models/gold/core/core__dim_labels.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,8 @@ SELECT
label_type,
label_subtype,
project_name,
COALESCE (
labels_id,
{{ dbt_utils.generate_surrogate_key(
['address']
) }}
) AS dim_labels_id,
COALESCE(
inserted_timestamp,
'2000-01-01'
) AS inserted_timestamp,
COALESCE(
modified_timestamp,
'2000-01-01'
) AS modified_timestamp
labels_combined_id AS dim_labels_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__labels') }}
2 changes: 1 addition & 1 deletion models/gold/core/core__dim_labels.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
models:
- name: core__dim_labels
description: '{{ doc("base_labels_table") }}'
description: '{{ doc("table_dim_labels") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
Expand Down
14 changes: 8 additions & 6 deletions models/silver/labels/silver__labels.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{{ config(
materialized = 'incremental',
unique_key = 'address',
unique_key = ['address', 'blockchain'],
incremental_strategy = 'merge',
merge_exclude_columns = ["inserted_timestamp"],
cluster_by = 'modified_timestamp::DATE',
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(address); DELETE FROM {{ this }} WHERE _is_deleted = TRUE;",
tags = ['non_realtime']
) }}

Expand All @@ -15,9 +18,8 @@ SELECT
label_subtype,
address_name,
project_name,
{{ dbt_utils.generate_surrogate_key(
['address']
) }} AS labels_id,
_is_deleted,
labels_combined_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
Expand All @@ -27,10 +29,10 @@ WHERE
1 = 1

{% if is_incremental() %}
AND insert_date >= (
AND modified_timestamp >= (
SELECT
MAX(
insert_date
modified_timestamp
)
FROM
{{ this }}
Expand Down
1 change: 1 addition & 0 deletions models/sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ sources:
- name: asset_metadata_priority
- name: asset_metadata_all_providers
- name: near_address_encoded
- name: labels_combined
- name: ethereum_silver
database: ethereum
schema: silver
Expand Down

0 comments on commit b51da57

Please sign in to comment.