-
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
Implement atomic swap for Snowflake #724
Comments
look into snowflake atomic swap. then instead of doing: create temp, drop old, rename do: create temp, atomic swap, drop old |
@cmcarthur It seems possible in the flow that you're suggesting that there could still be a leftover temporary table in certain error conditions. I had kind of assumed that we would need to explicitly check for the existence of such a temporary table in the materialization code and drop it if it existed. thoughts on that? |
This may not be an issue right now, because of quoting changes and improvements to how we drop tmp relations before running models. But there is a bigger issue around Snowflake transactions. We write materialization code assuming transactional DDL is possible. Snowflake does not have any transactional DDL. So while this code might work fine today, it would be easy for us to make a simple seeming change that actually creates major dbt bugs. Kicking this out of 0.10.2 but we should review this later on. |
We don't need to atomic swap ever on Snowflake, as the best option is to use |
@drewbanin is that what we're doing right now-- that's new-ish, right? |
Snowflake doesn't have a concept of transactions as Redshift does. If it succeeds in creating a
MODEL_NAME__dbt_tmp
view/table but encounters an error before renaming it toMODEL_NAME
, the tmp view/table sticks around. The user must manually drop the tmp view/table, or the next run will fail (as below), in either case yielding a disruption to the workflow.This has been caused by failing post-hooks, which cannot currently be after-committed due to this issue.
A simple solution could be to replace
with
but after a cursory look I'm not sure where that code is generated within dbt.
The text was updated successfully, but these errors were encountered: