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

Snowflake table materialization can drop the wrong type of backup table #1103

Closed
drewbanin opened this issue Oct 30, 2018 · 0 comments
Closed
Assignees
Labels
bug Something isn't working snowflake
Milestone

Comments

@drewbanin
Copy link
Contributor

drewbanin commented Oct 30, 2018

Issue

Issue description

dbt's Snowflake table materialization can errantly assume that an existing backup relation is of the wrong type. The materialization assumes that the backup_relation is of the same type as the old_relation, which is not necessarily true:

https://github.com/fishtown-analytics/dbt/blob/371e8b438ab0939f000e3844162c50644f19d6d8/dbt/include/global_project/macros/materializations/table/snowflake_table.sql#L17

Results

dbt issued a drop table ... statement whereas it should have issued a drop view ... statement for the backup relation.

System information

The output of dbt --version:

>= 0.10.2

Steps to reproduce

The database needs to be in a very weird state to trigger this bug. There needs to be a {identifier}__dbt_backup relation with a different type than the {identifier} relation.

schema.test_relation <view>
schema.test_relation__dbt_backup <table>

Then run a model like:

-- models/test_relation.sql

{{ config(materialized='table') }}

select 1 as id

^ Importantly, this needs to be materialized as a table. The view materialization does not suffer from this bug, as we do not use a backup relation there. See also: #1101

@drewbanin drewbanin added bug Something isn't working snowflake labels Oct 30, 2018
@drewbanin drewbanin modified the milestone: Grace Kelly Nov 28, 2018
@beckjake beckjake self-assigned this Dec 4, 2018
beckjake added a commit that referenced this issue Dec 5, 2018
…wrong-backup-type

drop the correct relation type on snowflake when building tables [#1103]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working snowflake
Projects
None yet
Development

No branches or pull requests

2 participants