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

[Bug] DBT Creating Backup Dynamic Tables in Snowflake #1028

Closed
2 tasks done
kylienhu opened this issue May 8, 2024 · 1 comment
Closed
2 tasks done

[Bug] DBT Creating Backup Dynamic Tables in Snowflake #1028

kylienhu opened this issue May 8, 2024 · 1 comment
Labels
bug Something isn't working duplicate

Comments

@kylienhu
Copy link

kylienhu commented May 8, 2024

Is this a new bug in dbt-snowflake?

  • I believe this is a new bug in dbt-snowflake
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

We had errors with our dynamic tables on May 8 on dbt Cloud stating that the dynamic table has a '__DBT_BACKUP' version that already exists.

image

We did some investigation in Snowflake and found that dbt was running these commands:
drop table if exists "OPR_THD"."DBT_THD"."OPR_PRO_CHANNEL_ORDER_DETAIL_DT__dbt_backup" cascade
alter table "OPR_THD"."DBT_THD"."OPR_PRO_CHANNEL_ORDER_DETAIL_DT" rename to OPR_PRO_CHANNEL_ORDER_DETAIL_DT__dbt_backup;

It looks like dbt was creating a backup version when running a 'create or replace' command on the dynamic table. However, dbt didn't specify the database/schema when doing the renaming, and the backup table ended up being in a completely different database/schema than where the original table sits. Therefore, the drop command didn't actually drop the backup.

In our case, our backups are put in the STAGING1 database, while the production tables are in OPR_THD.

image

We also notice that the backups are set at a 10 minutes lag time similar to the production tables. This is causing refresh delays for the production tables since they share the same warehouse and resources with the backups. Snowflake would refresh all dynamic tables at the exact same timestamps. The production table was at around 99% meeting target lag prior to when the backups were created.

Production table
image

Backup
image

Expected Behavior

We expect that the backups are created in the same database and schema as the production tables and the drop command will drop them as needed.
We expect that the backups do not have the same target lag and won't affect the production refreshes.

Steps To Reproduce

In our 'Deployment_v1' environment, run command
dbt build -s +models/operational_data_sets/opr_thd

Relevant log output

No response

Environment

- OS: Linux
- Python:3.10
- dbt-core: 1.7
- dbt-snowflake:

Additional Context

No response

@kylienhu kylienhu added bug Something isn't working triage labels May 8, 2024
@jtcohen6 jtcohen6 added duplicate and removed triage labels May 10, 2024
@jtcohen6
Copy link
Contributor

@kylienhu Thanks for opening — there are actually two issues here, the first being the one you mention (unqualified rename), though the underlying cause was a change that Snowflake made to the return types of show terse objects.

This comment has the latest updates, as well as what I believe to be a viable workaround to unblock yourself in the meantime:

I've also opened a separate bug report for the unqualified rename:

I'm going to close this issue as a duplicate.

@jtcohen6 jtcohen6 closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate
Projects
None yet
Development

No branches or pull requests

2 participants