Replies: 7 comments 1 reply
-
@zhyzhkea , thank you for mentioning cloning as a possible feature for SnowDDL. I considered it initially, but cloning has too many limitations and various issues associated with it. It's nice feature for marketing, but not so good for an actual production usage. FIrst of all, please check the long list of official limitations here: https://docs.snowflake.com/en/user-guide/object-clone The most problematic point from this list is the "clone" operation potentially failing mid-way due to issues with data retention. Unfortunately, this operation is not atomic. Additionally, cloning conflicts with SnowDDL access management features related to SCHEMA ROLES (read more about role hierarchy). Cloned objects inherit privileges and ownership, which must be completely re-assigned afterwards. We tend to recommend a completely different approach.
Basically, you should add With this approach each developer or each CI/CD script can test the whole tree of ETL jobs simultaneously and independently from each other, which leads to very high confidence when finally pushing changes to PROD Snowflake account. Also, you'll have zero chance of PROD breaking DEV or vice versa. |
Beta Was this translation helpful? Give feedback.
-
Alternatively, we could potentially add a limited support for cloning, but only if:
|
Beta Was this translation helpful? Give feedback.
-
I was proposing to do it only for tables. The rest of the objects could be created using .yml files. If cloning is done at the schema level, schema objects would be owned by the source owner role but if tables are cloned individually in a loop, then tables would be owned by the active role (developer role). Zero-copy clone does not require ETL or sampling. It is fast and represents actual data from the upper environment. This scenario will work only for teams that do not have access to account-level privileges and all SDLC environments are databases under one enterprise account. Cloning from another account is not supported and databases built from share are read-only which defeats the purpose. |
Beta Was this translation helpful? Give feedback.
-
@zhyzhkea , I'll make a few tests and hopefully push an initial MVP-version with cloning support. I am currently thinking about the following implementation details:
With this approach tables will be cloned with proper future grants. With this approach SEQUENCEs will be correctly re-assigned right after cloning. Other objects will not be cloned and will be created from scratch instead. Sometimes it may lead to extra costs, if you have Does it sound good for you? Do I miss any other essential features? |
Beta Was this translation helpful? Give feedback.
-
@zhyzhkea , I've pushed an initial version of cloning. You may give it a try since Add CLI argument Cloning happens after creation of Only tables which currently do not exist in destination databases are cloned. If you want to clone a table one more time, you should run You'll see some Only tables are cloned. All other types of objects are created from scratch, which may or may not cause some undesirable effects. We'll see how it goes. Please let me know if it works for you. If it goes well, I'll make it an official feature. Thank you! |
Beta Was this translation helpful? Give feedback.
-
It sounds very good. Thank you.
…On Tue, Jul 18, 2023 at 12:50 PM littleK0i ***@***.***> wrote:
@zhyzhkea <https://github.com/zhyzhkea> , I've pushed an initial version
of cloning. You may give it a try since 0.18.0.
Add CLI argument --clone-table together with --env-prefix. Tables from
"source databases" (without prefix) will be cloned to "destination
databases" (with prefix).
Cloning happens after creation of SCHEMA, SCHEMA_ROLE, but before TABLE.
Only tables which currently do not exist in destination databases are
cloned. If you want to clone a table one more time, you should run snowddl
--env-prefix=XXX destroy to cleanup and re-create databases with prefix
again. Alternatively, you may drop specific tables from destination
database manually.
You'll see some ALTER TABLE commands being applied or suggested by
SnowDDL. It happens because cloned tables inherit a lot of links to objects
in source database. SnowDDL tries to fix it and switch these links to
destination database. It is especially noticeable for SEQUENCE and
constraints like FOREIGN_KEY.
Only tables are cloned. Everything else is created from scratch, which may
or may not cause some undesirable effects. We'll see how it goes.
Please let me know if it works for you. If it goes well, I'll make it an
official feature.
Thank you!
—
Reply to this email directly, view it on GitHub
<#48 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIEPEM56R5B4GYLOCRGHW3TXQ3SIZANCNFSM6AAAAAA2J3ZZ74>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi @littleK0i, I am currently testing the Not sure if this was done on purpose, but I am wondering why when I re-run the |
Beta Was this translation helpful? Give feedback.
-
Usually, developers start to work on new assignments by creating a feature environment but they need the latest data from some official SDLC environment as a starting point. It would be beneficial to have another option to clone vs. just create table?
CREATE <object_type> <object_name> CLONE <source_object_name>
Beta Was this translation helpful? Give feedback.
All reactions