use fsc-utils

This commit is contained in:
Eric Laurello 2024-11-20 10:38:52 -05:00
parent f4304897e5
commit 5d6c445d27
3 changed files with 2 additions and 39 deletions

View File

@ -39,7 +39,7 @@ models:
columns: true
+on_schema_change: "append_new_columns"
osmosis_models:
+pre-hook: '{{ set_query_tag() }}' # Changed from query_tag to pre-hook
+pre-hook: '{{ fsc_utils.set_query_tag() }}' # Changed from query_tag to pre-hook
tests:

View File

@ -1,37 +0,0 @@
{% macro get_query_tag() %}
{# Get the full path of the model #}
{% set model_path = model.path | string %}
{% set folder_path = '/'.join(model_path.split('/')[:-1]) %}
{# Get core folders from vars #}
{% set core_folders = var('core_folders') %}
{# Initialize is_core and check each path pattern #}
{% set ns = namespace(is_core=false) %}
{% for folder in core_folders %}
{% if folder in folder_path %}
{% set ns.is_core = true %}
{% endif %}
{% endfor %}
{# Build the JSON query tag #}
{% set tag_dict = {
"project": project_name,
"model": model.name,
"model_type": "core" if ns.is_core else "non_core",
"invocation_id": invocation_id,
"dbt_tags": config.get('tags', [])
} %}
{% set query_tag = tojson(tag_dict) %}
{# Return the properly escaped string #}
{{ return("'" ~ query_tag ~ "'") }}
{% endmacro %}
{% macro set_query_tag() %}
{% set tag = get_query_tag() %}
{% do run_query("alter session set query_tag = " ~ tag) %}
{{ return("") }}
{% endmacro %}

View File

@ -6,6 +6,6 @@ packages:
- package: dbt-labs/dbt_external_tables
version: 0.8.0
- git: https://github.com/FlipsideCrypto/fsc-utils.git
revision: v1.29.0
revision: v1.32.0
- package: get-select/dbt_snowflake_query_tags
version: [">=2.0.0", "<3.0.0"]