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

Session Parameters - query tag and timezone #2829

Open
achicoine-coveo opened this issue Jun 26, 2024 · 0 comments
Open

Session Parameters - query tag and timezone #2829

achicoine-coveo opened this issue Jun 26, 2024 · 0 comments
Labels
Engine: Snowflake Issues related to Snowflake Improvement Improves existing functionality

Comments

@achicoine-coveo
Copy link

My company is using query tags in Snowflake to do cost reporting. I was trying to find a way to set query tags at the session level, but it looks like that's not supported at the moment. It could also be useful to set them at the model level.

Looking at the python session for Snowflake: https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#label-snowflake-connector-methods-connect

timezone can be set in the session.
From doing code with this in the past I believe the query tag has to be set once the session is obtained using an alter session.

Would all session parameters need to be listed and documented or could you do it in a generic way running alter session set key = value for all the extra ones? There's a lot of parameters in Snowflake and even more in spark and I wouldn't expect sqlmesh to support all of them explicitly and with documentation, but passing them through would be great.
https://docs.snowflake.com/en/sql-reference/parameters

Docs on what Sqlmesh supports currently for Snowflake:
https://sqlmesh.readthedocs.io/en/stable/integrations/engines/snowflake/#installation

I believe this is the relevant code:

class SnowflakeConnectionConfig(ConnectionConfig):

In the code for dbt query tag is seen, but I believe it falls through the cracks and isn't used.

query_tag: t.Optional[str] = None

Workaround: for now I can set the timezone in the models that need it with a pre-statement, but setting the query tag and other parameters in every model would get annoying and it would be easy to miss one. I would also need the query tags to be on every query in the sessions and not just the ones directly in the models.

@izeigerman izeigerman added Improvement Improves existing functionality Engine: Snowflake Issues related to Snowflake labels Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Engine: Snowflake Issues related to Snowflake Improvement Improves existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants