diff --git a/core/dbt/include/global_project/macros/materializations/archive/archive.sql b/core/dbt/include/global_project/macros/materializations/archive/archive.sql index 6e3e96c5f59..ead07b657d7 100644 --- a/core/dbt/include/global_project/macros/materializations/archive/archive.sql +++ b/core/dbt/include/global_project/macros/materializations/archive/archive.sql @@ -253,7 +253,14 @@ {%- set target_table = model.get('alias', model.get('name')) -%} {%- set strategy = config.get('strategy') -%} - {{ create_schema(target_database, target_schema) }} + {% set information_schema = api.Relation.create( + database=target_database, + schema=target_schema, + identifier=target_table).information_schema() %} + + {% if not check_schema_exists(information_schema, target_schema) %} + {{ create_schema(target_database, target_schema) }} + {% endif %} {%- set target_relation = adapter.get_relation( database=target_database, diff --git a/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql b/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql index 71bb137781c..1c87ce4dc18 100644 --- a/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql +++ b/plugins/bigquery/dbt/include/bigquery/macros/adapters.sql @@ -74,6 +74,6 @@ {% endmacro %} -{% macro bigquery__check_schema_exists(database, schema) %} - {{ return(adapter.check_schema_exists(database, schema)) }} +{% macro bigquery__check_schema_exists(information_schema, schema) %} + {{ return(adapter.check_schema_exists(information_schema.database, schema)) }} {% endmacro %}