-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* override seed types * s/_columns/column_types/g * pep8 * fix unit tests, add integration test * add bq, snowflake tests for seed type overrides
- Loading branch information
Showing
16 changed files
with
158 additions
and
18 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
'pre-hook', | ||
'post-hook', | ||
'vars', | ||
'column_types', | ||
'bind', | ||
] | ||
|
||
|
15 changes: 15 additions & 0 deletions
15
test/integration/005_simple_seed_test/macros/schema_test.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,15 @@ | ||
|
||
{% macro test_column_type(model, field, type) %} | ||
|
||
{% set cols = adapter.get_columns_in_table(model.schema, model.name) %} | ||
|
||
{% set col_types = {} %} | ||
{% for col in cols %} | ||
{% set _ = col_types.update({col.name: col.data_type}) %} | ||
{% endfor %} | ||
|
||
{% set val = 0 if col_types[field] == type else 1 %} | ||
|
||
select {{ val }} as pass_fail | ||
|
||
{% endmacro %} |
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,6 @@ | ||
|
||
seed_enabled: | ||
constraints: | ||
column_type: | ||
- {field: id, type: 'FLOAT' } | ||
- {field: birthday, type: 'STRING' } |
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,6 @@ | ||
|
||
seed_enabled: | ||
constraints: | ||
column_type: | ||
- {field: id, type: 'character varying(255)' } | ||
- {field: birthday, type: 'date' } |
6 changes: 6 additions & 0 deletions
6
test/integration/005_simple_seed_test/models-snowflake/schema.yml
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,6 @@ | ||
|
||
seed_enabled: | ||
constraints: | ||
column_type: | ||
- {field: ID, type: 'FLOAT' } | ||
- {field: BIRTHDAY, type: 'character varying(16777216)' } |
Empty file.
87 changes: 87 additions & 0 deletions
87
test/integration/005_simple_seed_test/test_seed_type_override.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,87 @@ | ||
from nose.plugins.attrib import attr | ||
from test.integration.base import DBTIntegrationTest | ||
|
||
class TestSimpleSeedColumnOverride(DBTIntegrationTest): | ||
|
||
@property | ||
def schema(self): | ||
return "simple_seed_005" | ||
|
||
@property | ||
def project_config(self): | ||
return { | ||
"data-paths": ['test/integration/005_simple_seed_test/data-config'], | ||
"macro-paths": ['test/integration/005_simple_seed_test/macros'], | ||
"seeds": { | ||
"test": { | ||
"enabled": False, | ||
"seed_enabled": { | ||
"enabled": True, | ||
"column_types": self.seed_types() | ||
}, | ||
} | ||
} | ||
} | ||
|
||
class TestSimpleSeedColumnOverridePostgres(TestSimpleSeedColumnOverride): | ||
@property | ||
def models(self): | ||
return "test/integration/005_simple_seed_test/models-pg" | ||
|
||
@property | ||
def profile_config(self): | ||
return self.postgres_profile() | ||
|
||
def seed_types(self): | ||
return { | ||
"id": "text", | ||
"birthday": "date", | ||
} | ||
|
||
@attr(type='postgres') | ||
def test_simple_seed_with_column_override_snowflake(self): | ||
self.run_dbt(["seed"]) | ||
self.run_dbt(["test"]) | ||
|
||
|
||
class TestSimpleSeedColumnOverrideSnowflake(TestSimpleSeedColumnOverride): | ||
@property | ||
def models(self): | ||
return "test/integration/005_simple_seed_test/models-snowflake" | ||
|
||
def seed_types(self): | ||
return { | ||
"id": "FLOAT", | ||
"birthday": "TEXT", | ||
} | ||
|
||
@property | ||
def profile_config(self): | ||
return self.snowflake_profile() | ||
|
||
@attr(type='snowflake') | ||
def test_simple_seed_with_column_override_snowflake(self): | ||
self.run_dbt(["seed"]) | ||
self.run_dbt(["test"]) | ||
|
||
class TestSimpleSeedColumnOverrideBQ(TestSimpleSeedColumnOverride): | ||
@property | ||
def models(self): | ||
return "test/integration/005_simple_seed_test/models-bq" | ||
|
||
def seed_types(self): | ||
return { | ||
"id": "FLOAT64", | ||
"birthday": "STRING", | ||
} | ||
|
||
@property | ||
def profile_config(self): | ||
return self.bigquery_profile() | ||
|
||
@attr(type='bigquery') | ||
def test_simple_seed_with_column_override_bq(self): | ||
self.run_dbt(["seed"]) | ||
self.run_dbt(["test"]) | ||
|
||
|
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