Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query tag node name #25

Closed
wants to merge 3 commits into from

Conversation

jnschurig
Copy link

Add model name to base query tag

In any model in which a query tag is valuable, node name is also very helpful. While the node name is already in the query comment, it's quite large and can clutter up the sql quite a bit. Having the model name in the query tag (rather than only in query comment) also improves speed and reliability of parsing the node name successfully.

@jnschurig jnschurig had a problem deploying to Approve Integration Tests April 24, 2024 23:27 — with GitHub Actions Failure
@jnschurig jnschurig had a problem deploying to Approve Integration Tests April 24, 2024 23:27 — with GitHub Actions Failure
@ian-whitestone
Copy link
Contributor

Thanks @jnschurig for the contribution! I can understand how having the node name in the query tag would be helpful for quick analysis.

I'm personally good with this change, but would like to hold off on merging & cutting a new version until next week when our main package maintainer is back from vacation (May 1).

@jnschurig
Copy link
Author

Thanks @jnschurig for the contribution! I can understand how having the node name in the query tag would be helpful for quick analysis.

I'm personally good with this change, but would like to hold off on merging & cutting a new version until next week when our main package maintainer is back from vacation (May 1).

Thanks for responding! I realize it's a very small change to cut a new version for, so I totally understand wanting to wait for the primary to return. Looking forward to hearing back.

@NiallRees
Copy link
Member

NiallRees commented May 2, 2024

Hi @jnschurig - thanks for this PR. Totally recognise that different use-cases will warrant different metadata in comments and query tags. We currently have a solution for adding custom query comment metadata outlined here, but custom query tag metadata can only be set in the model or profiles.yml level currently.

How would you feel about allowing users to set custom query tags via an extra kwarg, like we do with comments? So the
instructions would look like:


If you'd like to add custom metadata to the query tag, you can use the instructions normally reserved for dbt < 1.2:

Create a folder named macros in your dbt project's top level directory (if it doesn't exist). Inside, make a new file called query_tags.sql with the following content:

{% macro set_query_tag() -%}
{% do return(dbt_snowflake_query_tags.set_query_tag(extra={"node_name": model.name })) %}
{% endmacro %}

{% macro unset_query_tag(original_query_tag) -%}
{% do return(dbt_snowflake_query_tags.unset_query_tag(original_query_tag)) %}
{% endmacro %}

The extra kwarg can be supplied with a dictionary containing any additional metadata you'd like to add to the query tags.


If you're aligned and want to take a stab at it, please do!

@NiallRees
Copy link
Member

Hey @jnschurig - we've just made a new version of this package which lets you add arbitrary metadata to the query tag via an extra kwarg: https://github.com/get-select/dbt-snowflake-query-tags?tab=readme-ov-file#extra-kwarg-1

I'm going to close this as I think that lets you achieve this without new code.

@NiallRees NiallRees closed this May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants