Skip to content

Commit

Permalink
give bigquery list_schemas/check_schema_exist macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Beck committed Apr 23, 2019
1 parent 416cc72 commit 2efae5a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/bigquery/dbt/adapters/bigquery/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def rename_relation(self, from_relation, to_relation):
'`rename_relation` is not implemented for this adapter!'
)

@available
def list_schemas(self, database):
conn = self.connections.get_thread_connection()
client = conn.handle
Expand All @@ -84,6 +85,11 @@ def list_schemas(self, database):
include_all=True)
return [ds.dataset_id for ds in all_datasets]

@available
def check_schema_exists(self, database, schema):
superself = super(BigQueryAdapter, self)
return superself.check_schema_exists(database, schema)

def get_columns_in_relation(self, relation):
try:
table = self.connections.get_bq_table(
Expand Down
10 changes: 10 additions & 0 deletions plugins/bigquery/dbt/include/bigquery/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,13 @@
{% macro bigquery__current_timestamp() -%}
CURRENT_TIMESTAMP()
{%- endmacro %}


{% macro bigquery__list_schemas(database) %}
{{ return(adapter.list_schemas()) }}
{% endmacro %}


{% macro bigquery__check_schema_exists(database, schema) %}
{{ return(adapter.check_schema_exists(database, schema)) }}
{% endmacro %}

0 comments on commit 2efae5a

Please sign in to comment.