Skip to content

Commit bd03171

Browse files
authored
Merge pull request #13 from oracle/fix/clean_global_temporary_table
Fix/clean global temporary table
2 parents 461f58c + 82c99a9 commit bd03171

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

dbt/include/oracle/macros/adapters.sql

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,12 @@
268268
{% endmacro %}
269269

270270
{% macro oracle__truncate_relation(relation) -%}
271-
{% call statement('truncate_relation') -%}
272-
truncate table {{ relation.quote(schema=False, identifier=False) }}
273-
{%- endcall %}
271+
{#-- To avoid `ORA-01702: a view is not appropriate here` we check that the relation to be truncated is a table #}
272+
{% if relation.is_table %}
273+
{% call statement('truncate_relation') -%}
274+
truncate table {{ relation.quote(schema=False, identifier=False) }}
275+
{%- endcall %}
276+
{% endif %}
274277
{% endmacro %}
275278

276279
{% macro oracle__rename_relation(from_relation, to_relation) -%}

dbt/include/oracle/macros/materializations/incremental/incremental.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
{% do adapter.commit() %}
6363

6464
{% for rel in to_drop %}
65+
{% do adapter.truncate_relation(rel) %}
6566
{% do adapter.drop_relation(rel) %}
6667
{% endfor %}
6768

dbt/include/oracle/macros/materializations/snapshot/snapshot.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
{{ adapter.dispatch('post_snapshot')(staging_relation) }}
3636
{% endmacro %}
3737

38-
{% macro default__post_snapshot(staging_relation) %}
39-
{# no-op #}
38+
{% macro oracle__post_snapshot(staging_relation) %}
39+
{% do adapter.truncate_relation(staging_relation) %}
40+
{% do adapter.drop_relation(staging_relation) %}
4041
{% endmacro %}
4142

4243

0 commit comments

Comments
 (0)