Skip to content

Commit

Permalink
if the schema exists, do not try to create it
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Beck committed Apr 12, 2019
1 parent 4894215 commit 7a4dae4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions plugins/bigquery/dbt/include/bigquery/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

0 comments on commit 7a4dae4

Please sign in to comment.