-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1983 from fishtown-analytics/fix/restore-drop-schema
Restore drop_schema to adapter in jinja context (#1980)
- Loading branch information
Showing
9 changed files
with
112 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/integration/054_adapter_methods_test/models/expected.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- make sure this runs after 'model' | ||
-- {{ ref('model') }} | ||
select 2 as id |
19 changes: 19 additions & 0 deletions
19
test/integration/054_adapter_methods_test/models/model.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
{% set upstream = ref('upstream') %} | ||
|
||
{% if execute %} | ||
{# don't ever do any of this #} | ||
{%- do adapter.drop_schema(upstream.database, upstream.schema) -%} | ||
{% set existing = adapter.get_relation(upstream.database, upstream.schema, upstream.identifier) %} | ||
{% if existing is not none %} | ||
{% do exceptions.raise_compiler_error('expected ' ~ ' to not exist, but it did') %} | ||
{% endif %} | ||
|
||
{%- do adapter.create_schema(upstream.database, upstream.schema) -%} | ||
|
||
{% set sql = create_view_as(upstream, 'select 2 as id') %} | ||
{% do run_query(sql) %} | ||
{% endif %} | ||
|
||
|
||
select * from {{ upstream }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
select 1 as id |
31 changes: 31 additions & 0 deletions
31
test/integration/054_adapter_methods_test/test_adapter_methods.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from test.integration.base import DBTIntegrationTest, use_profile | ||
|
||
|
||
class TestBaseCaching(DBTIntegrationTest): | ||
@property | ||
def schema(self): | ||
return "caching_038" | ||
|
||
@property | ||
def models(self): | ||
return "models" | ||
|
||
@use_profile('postgres') | ||
def test_postgres_adapter_methods(self): | ||
self.run_dbt() | ||
self.assertTablesEqual('model', 'expected') | ||
|
||
@use_profile('redshift') | ||
def test_redshift_adapter_methods(self): | ||
self.run_dbt() | ||
self.assertTablesEqual('model', 'expected') | ||
|
||
@use_profile('snowflake') | ||
def test_snowflake_adapter_methods(self): | ||
self.run_dbt() | ||
self.assertTablesEqual('MODEL', 'EXPECTED') | ||
|
||
@use_profile('bigquery') | ||
def test_bigquery_adapter_methods(self): | ||
self.run_dbt() | ||
self.assertTablesEqual('model', 'expected') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters