diff --git a/models/gold/core/core__dim_labels.sql b/models/gold/core/core__dim_labels.sql new file mode 100644 index 0000000..79e02d2 --- /dev/null +++ b/models/gold/core/core__dim_labels.sql @@ -0,0 +1,34 @@ +{{ config( + materialized = 'incremental', + unique_key = ['address'], + incremental_strategy = 'merge', + merge_exclude_columns = ["inserted_timestamp"], + post_hook = ["ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(address)", "DELETE FROM {{ this }} WHERE address in (select address from {{ ref('silver__crosschain_labels') }} where _is_deleted = TRUE);",], + tags = ['gold','core'] +) }} + +SELECT + blockchain, + creator, + address, + label_type, + label_subtype, + project_name AS label, + address_name, + labels_combined_id AS dim_labels_id, + inserted_timestamp, + modified_timestamp +FROM + {{ ref('silver__crosschain_labels') }} + +{% if is_incremental() %} +WHERE + modified_timestamp >= ( + SELECT + MAX( + modified_timestamp + ) + FROM + {{ this }} + ) +{% endif %} diff --git a/models/gold/core/gold_core.yml b/models/gold/core/gold_core.yml index d3f2309..67c445c 100644 --- a/models/gold/core/gold_core.yml +++ b/models/gold/core/gold_core.yml @@ -659,4 +659,34 @@ models: field: block_timestamp interval: 12 severity: error - tags: ['test_recency'] \ No newline at end of file + tags: ['test_recency'] + + + - name: core__dim_labels + description: "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/).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." + + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - ADDRESS + columns: + - name: ADDRESS + description: "Raw address string" + - name: BLOCKCHAIN + description: "In this table, always ton. Used to join to cross-chain tables." + - name: CREATOR + description: "Name of the label creator - for now, this will always be \"Flipside.\"" + - name: LABEL_TYPE + description: "A broad category that describes what a label is representing." + - name: LABEL_SUBTYPE + description: "Adds more detail to the label type." + - name: LABEL + description: "The label or name of the address." + - name: ADDRESS_NAME + description: "Name of the labeled address" + - name: DIM_LABELS_ID + description: "Unique primary key for the dimension table, used as the main identifier for each record." + - name: INSERTED_TIMESTAMP + description: "Timestamp when this record was inserted." + - name: MODIFIED_TIMESTAMP + description: "Timestamp when this record was last modified." \ No newline at end of file diff --git a/models/silver/labels/silver__crosschain_labels.sql b/models/silver/labels/silver__crosschain_labels.sql new file mode 100644 index 0000000..d049d01 --- /dev/null +++ b/models/silver/labels/silver__crosschain_labels.sql @@ -0,0 +1,24 @@ +{{ config( + materialized = 'view', + tags = ['scheduled_core'] +) }} + +SELECT + blockchain, + address, + creator, + label_type, + label_subtype, + address_name, + project_name, + _is_deleted, + labels_combined_id, + inserted_timestamp, + modified_timestamp +FROM + {{ source( + 'crosschain_silver', + 'labels_combined' + ) }} +WHERE + blockchain = 'sui' diff --git a/models/silver/labels/silver__crosschain_labels.yml b/models/silver/labels/silver__crosschain_labels.yml new file mode 100644 index 0000000..218f554 --- /dev/null +++ b/models/silver/labels/silver__crosschain_labels.yml @@ -0,0 +1,16 @@ +version: 2 +models: + - name: silver__crosschain_labels + columns: + - name: BLOCKCHAIN + - name: ADDRESS + - name: CREATOR + - name: LABEL_TYPE + - name: LABEL_SUBTYPE + - name: ADDRESS_NAME + - name: PROJECT_NAME + - name: _IS_DELETED + - name: LABELS_COMBINED_ID + - name: INSERTED_TIMESTAMP + - name: MODIFIED_TIMESTAMP + \ No newline at end of file