2024-09-25 19:35:33 +00:00
## Profile Set Up
#### Use the following within profiles.yml
----
```yml
2024-10-09 14:06:56 +00:00
< chain > : -- replace < chain > /< CHAIN > with the profile or name from, remove this comment in your yml
2024-09-25 19:35:33 +00:00
target: dev
outputs:
dev:
type: snowflake
2024-10-09 14:06:56 +00:00
account: < ACCOUNT >
2024-10-02 03:54:37 +00:00
role: INTERNAL_DEV
2024-10-09 14:06:56 +00:00
user: < USERNAME >
2024-10-02 03:54:37 +00:00
authenticator: externalbrowser
region: us-east-1
2024-10-09 14:06:56 +00:00
database: < CHAIN > _DEV
2024-10-02 03:54:37 +00:00
warehouse: DBT
2024-09-25 19:35:33 +00:00
schema: silver
2024-10-02 03:54:37 +00:00
threads: 4
2024-09-25 19:35:33 +00:00
client_session_keep_alive: False
2024-10-09 14:06:56 +00:00
query_tag: dbt_< USERNAME > _dev
2024-10-02 03:54:37 +00:00
2024-09-25 19:35:33 +00:00
prod:
type: snowflake
2024-10-09 14:06:56 +00:00
account: < ACCOUNT >
role: DBT_CLOUD_< CHAIN >
user: < USERNAME >
2024-10-02 03:54:37 +00:00
authenticator: externalbrowser
region: us-east-1
2024-10-09 14:06:56 +00:00
database: < CHAIN >
warehouse: DBT_CLOUD_< CHAIN >
2024-09-25 19:35:33 +00:00
schema: silver
2024-10-02 03:54:37 +00:00
threads: 4
2024-09-25 19:35:33 +00:00
client_session_keep_alive: False
2024-10-09 14:06:56 +00:00
query_tag: dbt_< USERNAME > _dev
2024-09-25 19:35:33 +00:00
```
2024-10-02 03:54:37 +00:00
### Common DBT Run Variables
2024-09-25 19:35:33 +00:00
2024-10-02 03:54:37 +00:00
The following variables can be used to control various aspects of the dbt run. Use them with the `--vars` flag when running dbt commands.
2024-09-25 19:35:33 +00:00
2024-10-02 03:54:37 +00:00
| Variable | Description | Example Usage |
|----------|-------------|---------------|
| `UPDATE_UDFS_AND_SPS` | Update User Defined Functions and Stored Procedures. By default, this is set to False | `--vars '{"UPDATE_UDFS_AND_SPS":true}'` |
| `STREAMLINE_INVOKE_STREAMS` | Invoke Streamline processes. By default, this is set to False | `--vars '{"STREAMLINE_INVOKE_STREAMS":true}'` |
| `STREAMLINE_USE_DEV_FOR_EXTERNAL_TABLES` | Use development environment for external tables. By default, this is set to False | `--vars '{"STREAMLINE_USE_DEV_FOR_EXTERNAL_TABLES":true}'` |
| `HEAL_CURATED_MODEL` | Heal specific curated models. By default, this is set to an empty array []. See more below. | `--vars '{"HEAL_CURATED_MODEL":["axelar","across","celer_cbridge"]}'` |
| `UPDATE_SNOWFLAKE_TAGS` | Control updating of Snowflake tags. By default, this is set to False | `--vars '{"UPDATE_SNOWFLAKE_TAGS":false}'` |
| `START_GHA_TASKS` | Start GitHub Actions tasks. By default, this is set to False | `--vars '{"START_GHA_TASKS":true}'` |
2024-09-25 19:35:33 +00:00
2024-10-02 03:54:37 +00:00
#### Example Commands
1. Update UDFs and SPs:
```
dbt run --vars '{"UPDATE_UDFS_AND_SPS":true}' -m ...
```
2. Invoke Streamline and use dev for external tables:
```
dbt run --vars '{"STREAMLINE_INVOKE_STREAMS":true,"STREAMLINE_USE_DEV_FOR_EXTERNAL_TABLES":true}' -m ...
```
3. Heal specific curated models:
```
dbt run --vars '{"HEAL_CURATED_MODEL":["axelar","across","celer_cbridge"]}' -m ...
```
4. Update Snowflake tags for a specific model:
```
dbt run --vars '{"UPDATE_SNOWFLAKE_TAGS":true}' -s models/silver/utilities/silver__number_sequence.sql
```
5. Start GHA tasks:
```
dbt seed -s github_actions__workflows & & dbt run -m models/github_actions --full-refresh & & dbt run-operation fsc_utils.create_gha_tasks --vars '{"START_GHA_TASKS":True}'
```
2024-10-02 04:10:47 +00:00
6. Using two or more variables:
```
dbt run --vars '{"UPDATE_UDFS_AND_SPS":true,"STREAMLINE_INVOKE_STREAMS":true,"STREAMLINE_USE_DEV_FOR_EXTERNAL_TABLES":true}' -m ...
```
2024-10-02 03:54:37 +00:00
> Note: Replace `-m ...` with appropriate model selections or tags as needed for your project structure.
2024-10-09 16:00:44 +00:00
## FSC_EVM
`fsc_evm` is a collection of macros, models, and other resources that are used to build the Flipside Crypto EVM models.
2024-09-25 19:35:33 +00:00
2024-10-09 16:00:44 +00:00
For more information on the `fsc_evm` package, see the [FSC_EVMWiki ](https://github.com/FlipsideCrypto/fsc-evm/wiki ).
2024-09-25 19:35:33 +00:00
## Applying Model Tags
### Database / Schema level tags
2024-10-07 17:58:33 +00:00
Database and schema tags are applied via the `fsc_evm.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.
2024-09-25 19:35:33 +00:00
```
2024-10-07 17:58:33 +00:00
{{ fsc_evm.set_database_tag_value('SOME_DATABASE_TAG_KEY','SOME_DATABASE_TAG_VALUE') }}
{{ fsc_evm.set_schema_tag_value('SOME_SCHEMA_TAG_KEY','SOME_SCHEMA_TAG_VALUE') }}
2024-09-25 19:35:33 +00:00
```
### 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.
2024-10-09 13:57:48 +00:00
{% raw %}
2024-09-25 19:35:33 +00:00
{{ config(
...,
meta={
'database_tags':{
'table': {
'PURPOSE': 'SOME_PURPOSE'
}
}
},
...
) }}
2024-10-09 13:57:48 +00:00
{% endraw %}
2024-09-25 19:35:33 +00:00
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.
```
2024-10-02 03:54:37 +00:00
dbt run --vars '{"UPDATE_SNOWFLAKE_TAGS":False}' -s models/silver/utilities/silver__number_sequence.sql
2024-09-25 19:35:33 +00:00
```
### Querying for existing tags on a model in snowflake
```
select *
2024-10-09 14:06:56 +00:00
from table(< chain > .information_schema.tag_references('< chain > .core.fact_blocks', 'table'));
2024-09-25 19:35:33 +00:00
```