Skip to content

Commit

Permalink
Implement relations api dp fix (#729)
Browse files Browse the repository at this point in the history
* fix bq date partitioning

* fix for context vars (tmp table name)
  • Loading branch information
drewbanin committed Apr 9, 2018
1 parent cea3a43 commit 5ce7aa7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dbt/adapters/default/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ def drop_schema(cls, profile, schema, model_name=None):
@classmethod
def already_exists(cls, profile, schema, table, model_name=None):
# TODO add deprecation warning
relation = cls.get_relation(schema=schema, identifier=table)
relation = cls.get_relation(profile, schema=schema, identifier=table)
return relation is not None

@classmethod
Expand Down
7 changes: 5 additions & 2 deletions dbt/adapters/default/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def render(self):

if path_part is None:
continue
elif k == 'identifier':
path_part = self.table

parts.append(
self.quote_if(
Expand Down Expand Up @@ -156,7 +158,8 @@ def create_from_node(cls, profile, node, table_name=None, **kwargs):
return cls.create(
database=profile.get('dbname'),
schema=node.get('schema'),
identifier=table_name or node.get('name'),
identifier=node.get('name'),
table_name=table_name,
**kwargs)

@classmethod
Expand Down Expand Up @@ -205,7 +208,7 @@ def name(self):
# Here for compatibility with old Relation interface
@property
def table(self):
return self._table_name
return self.table_name

@property
def is_table(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@

-- build model
{% if partitions %}
{{ make_date_partitioned_table(model, target_relation, partitions, exists_not_as_table, verbose) }}
{# Create the dp-table if 1. it does not exist or 2. it existed, but we just dropped it #}
{%- set should_create = (old_relation is none or exists_not_as_table) -%}
{{ make_date_partitioned_table(model, target_relation, partitions, should_create, verbose) }}
{% else %}
{% call statement('main') -%}
{{ create_table_as(False, target_relation, sql) }}
Expand Down

0 comments on commit 5ce7aa7

Please sign in to comment.