Skip to content

Commit

Permalink
Merge pull request gocardless#28 from tucows/master
Browse files Browse the repository at this point in the history
Add DbtDocsGenerateOperator and extend DbtTestOperator
  • Loading branch information
andrewrjones authored Sep 28, 2020
2 parents 054891e + 38e5a0e commit bdfc3f3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
3 changes: 2 additions & 1 deletion airflow_dbt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
DbtSeedOperator,
DbtSnapshotOperator,
DbtRunOperator,
DbtTestOperator
DbtTestOperator,
DbtDocsGenerateOperator
)
10 changes: 10 additions & 0 deletions airflow_dbt/hooks/dbt_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def __init__(self,
dir='.',
vars=None,
full_refresh=False,
data=False,
schema=False,
models=None,
exclude=None,
select=None,
Expand All @@ -52,6 +54,8 @@ def __init__(self,
self.target = target
self.vars = vars
self.full_refresh = full_refresh
self.data = data
self.schema = schema
self.models = models
self.exclude = exclude
self.select = select
Expand Down Expand Up @@ -84,6 +88,12 @@ def run_cli(self, *command):
if self.vars is not None:
dbt_cmd.extend(['--vars', self._dump_vars()])

if self.data:
dbt_cmd.extend(['--data'])

if self.schema:
dbt_cmd.extend(['--schema'])

if self.models is not None:
dbt_cmd.extend(['--models', self.models])

Expand Down
3 changes: 2 additions & 1 deletion airflow_dbt/operators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
DbtSeedOperator,
DbtSnapshotOperator,
DbtRunOperator,
DbtTestOperator
DbtTestOperator,
DbtDocsGenerateOperator
)
16 changes: 16 additions & 0 deletions airflow_dbt/operators/dbt_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def __init__(self,
dbt_bin='dbt',
verbose=True,
full_refresh=False,
data=False,
schema=False,
*args,
**kwargs):
super(DbtBaseOperator, self).__init__(*args, **kwargs)
Expand All @@ -56,6 +58,8 @@ def __init__(self,
self.vars = vars
self.models = models
self.full_refresh = full_refresh
self.data = data
self.schema = schema
self.exclude = exclude
self.select = select
self.dbt_bin = dbt_bin
Expand All @@ -69,6 +73,8 @@ def create_hook(self):
dir=self.dir,
vars=self.vars,
full_refresh=self.full_refresh,
data=self.data,
schema=self.schema,
models=self.models,
exclude=self.exclude,
select=self.select,
Expand Down Expand Up @@ -96,6 +102,16 @@ def execute(self, context):
self.create_hook().run_cli('test')


class DbtDocsGenerateOperator(DbtBaseOperator):
@apply_defaults
def __init__(self, profiles_dir=None, target=None, *args, **kwargs):
super(DbtDocsGenerateOperator, self).__init__(profiles_dir=profiles_dir, target=target, *args,
**kwargs)

def execute(self, context):
self.create_hook().run_cli('docs', 'generate')


class DbtSnapshotOperator(DbtBaseOperator):
@apply_defaults
def __init__(self, profiles_dir=None, target=None, *args, **kwargs):
Expand Down

0 comments on commit bdfc3f3

Please sign in to comment.