Skip to content

Commit be4629d

Browse files
committed
Fix for issue #6 again. Issues with temp-relations not beeing removed.
1 parent 7ba26bf commit be4629d

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

dbt/include/sqlserver/macros/adapters.sql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
{%- endcall %}
4646
{% endmacro %}
4747
48+
{% macro sqlserver__drop_relation_script(relation) -%}
49+
drop {{ relation.type }} if exists {{ relation.schema }}.{{ relation.identifier }}
50+
{% endmacro %}
51+
4852
{% macro sqlserver__check_schema_exists(database, schema) -%}
4953
{% call statement('check_schema_exists', fetch_result=True, auto_begin=False) -%}
5054
--USE {{ database_name }}
@@ -84,19 +88,20 @@
8488
path={"identifier": relation.identifier ~ '_temp_view'},
8589
type='view')-%}
8690
87-
{{ drop_relation(tmp_relation) }}
91+
{{ sqlserver__drop_relation_script(tmp_relation) }}
8892
89-
{{ drop_relation(relation) }}
93+
{{ sqlserver__drop_relation_script(relation) }}
9094
9195
{{ create_view_as(tmp_relation, sql) }}
9296
9397
{{ sqlserver__insert_into_from(relation, tmp_relation) }}
9498
95-
{{ drop_relation(tmp_relation) }}
99+
{{ sqlserver__drop_relation_script(tmp_relation) }}
96100
97101
{% if not temporary and as_columnstore -%}
98102
{{ sqlserver__create_clustered_columnstore_index(relation) }}
99103
{% endif %}
104+
100105
{% endmacro %}_
101106
102107
{% macro sqlserver__insert_into_from(to_relation, from_relation) -%}

0 commit comments

Comments
 (0)