Closed podung closed 7 months ago
Thanks @podung, I think it's a good idea. If you have a complete PR for this, please let me know!
Thanks @sfc-gh-jhansen. I'll be getting to this soon!
@podung Do you have an update for us ?
Thanks for the follow up ping - I will attempt to get this ready this week.
Oops sorry - doing some branch management and didn't realize I had made this PR with my forked master
branch.
@sfc-gh-tmathew Not sure how to re-open this, but I'm prepping a new branch. Should I just open a new PR and mention this one?
@sfc-gh-tmathew - sorry, I cannot get this PR to re-open after moving my forked master. I thought I could by pushing some new commits, but it's not picking it up.
I'll get a branch ready. Let me know if you'd like a new PR that just mentions this one or if you'd prefer something else.
Thanks
Bummer.
@podung Would you able to get your changes to baseline from 3.6.0 release ? If so, a new PR would be best.
@sfc-gh-tmathew - Please see my new PR: https://github.com/Snowflake-Labs/schemachange/pull/210. I have completed what I believe are the required tasks and am rebased on latest master (which is just a few commits ahead of 3.6.0).
Let me know if you'd like any changes! Thanks!
PR: Configure Snowflake Schema via Config
I'd like the ability to optionally specify the
snowflake_schema
via config.Example of Problematic Script
Schemachange Error
Explanation
The
schemachange
docs specifyFor most objects, it is sufficient to just declare the db name and schema name in the proc / function / table declaration. However some objects (namely SQL UDTFs in this example) in snowflake seem to ensure the object can compile. Since a schema is not provided on the
SELECT ... FROM CUSTOMER
statement, and noUSE SCHEMA
directive has been set, the error occurs.Work-Arounds
In the UDTF, a fully qualified name can be given (e.g.
Select ... FROM {{ db_name }}.{{ schema_name }}.CUSTOMER
).In the migration, before the
CREATE OR REPLACE
directive, we can simply add the statementUSE SCHEMA {{ schema_name }};
Why this change is useful
Our team has a requirement to keep the object DDLs identical in each environment (Dev, test, prod, etc). There are a few instances where snowflake requires fully qualified object names to verify compilation during object creation (namely: SQL UDTFs). Instead of having to add the
USE SCHEMA {{ schema_name }};
directive in many of our migration files, we'd like to just supply the schema up front and haveschemcachange
execute the statement for us at the beginning of the run.Tasks left before PR should be accepted
Snowflake_Schema
configuration optional (how it is currently coded it will blow up if not supplied)If you are interested in this PR I would be happy to complete the above tasks. Thanks for the library and for the consideration.