-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add query_tag to the model hierarchy #1030
Comments
I can see this being useful in a few different situations.
I am considering starting work to resolve this issue and the above use cases make me think there may be at least 2 distinct places one would want to add a tag:
The second can easily be achieved with model hooks (this is not to say some centralized supported method should not be developed). I am however not sure how to go about setting query tag immediately after opening a connection so that all queries run regardless of their source are tagged. Any ideas on how to achieve that or other thoughts on the general problem before I dig in would be appreciated. |
hey @DrMcTaco - I like the way you're thinking about this feature! I agree - I think we should support query tags both at the model level and at the connection level. We'd very much welcome a PR for this change. Some rough implementation notes:
Beyond these things, we also need to think about what happens if a query_tag is provided for both the target and a model. The easiest approach would just be to run two Let me know what you think about all that :) |
Nice! For the model-level configs, you'll want to add the As far as the jinja code is concerned, I'd grab this config value from the jinja context with I'd try to run this query as early as possible in the materialization code as possible so that all of the SQL (eg. hooks) are executed with the correct query tag. It might also be a good idea to make a helper macro (like this one) that actually does the heavy lifting to run this One last thing to consider: dbt uses a connection pool to execute queries. Do we need to "reset" the |
Feature
Feature description
After starting to analyze our query history in some depth, I had the realization that it would be useful to be able to specify QUERY_TAG (snowflake concept) anywhere in the hierarchy, like the
materialization
configuration.This way, you can query snowflake query_history by the query tag. Maybe you set one query tag for your whole dbt project. Maybe you set it per model folder. Maybe you set it on specific models.
https://docs.snowflake.net/manuals/sql-reference/parameters.html#query-tag
https://stackoverflow.com/questions/50965558/snowflake-cli-snowsql-query-tagging
QUERY_TAG is a session parameter, so the solution might be to set it in snowflake's table and view materializations, if the query tag is set?
Who will this benefit?
Anyone using snowflake who would like more granular information in her query history.
The text was updated successfully, but these errors were encountered: