diff --git a/dbt/include/global_project/macros/adapters/common.sql b/dbt/include/global_project/macros/adapters/common.sql index 2863a578b9a..7800426b519 100644 --- a/dbt/include/global_project/macros/adapters/common.sql +++ b/dbt/include/global_project/macros/adapters/common.sql @@ -9,6 +9,10 @@ {%- endif -%} {%- endmacro %} +{% macro create_schema(schema_name) %} + create schema if not exists "{{ schema_name }}"; +{% endmacro %} + {% macro create_table_as(temporary, identifier, sql) -%} {{ adapter_macro('create_table_as', temporary, identifier, sql) }} diff --git a/dbt/include/global_project/macros/materializations/archive.sql b/dbt/include/global_project/macros/materializations/archive.sql index ae3eed76458..e91daf7d0e8 100644 --- a/dbt/include/global_project/macros/materializations/archive.sql +++ b/dbt/include/global_project/macros/materializations/archive.sql @@ -91,6 +91,10 @@ column('dbt_updated_at', 'timestamp', None) ] -%} + {% call statement() %} + {{ create_schema(target_schema) }} + {% endcall %} + {% call statement() %} {{ create_archive_table(target_schema, target_table, dest_columns) }} {% endcall %}