Skip to content

Commit

Permalink
Merge pull request gocardless#40 from etoulas/dbt-deps-operator
Browse files Browse the repository at this point in the history
Add dbt deps operator
  • Loading branch information
andrewrjones authored Sep 3, 2021
2 parents 40163d4 + 766f2e9 commit 768c314
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ There are five operators currently implemented:

* `DbtDocsGenerateOperator`
* Calls [`dbt docs generate`](https://docs.getdbt.com/reference/commands/cmd-docs)
* `DbtDepsOperator`
* Calls [`dbt deps`](https://docs.getdbt.com/docs/deps)
* `DbtSeedOperator`
* Calls [`dbt seed`](https://docs.getdbt.com/docs/seed)
* `DbtSnapshotOperator`
Expand Down
3 changes: 2 additions & 1 deletion airflow_dbt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
DbtSnapshotOperator,
DbtRunOperator,
DbtTestOperator,
DbtDocsGenerateOperator
DbtDocsGenerateOperator,
DbtDepsOperator
)
3 changes: 2 additions & 1 deletion airflow_dbt/operators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
DbtSnapshotOperator,
DbtRunOperator,
DbtTestOperator,
DbtDocsGenerateOperator
DbtDocsGenerateOperator,
DbtDepsOperator
)
9 changes: 9 additions & 0 deletions airflow_dbt/operators/dbt_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,12 @@ def __init__(self, profiles_dir=None, target=None, *args, **kwargs):

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


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

def execute(self, context):
self.create_hook().run_cli('deps')
12 changes: 11 additions & 1 deletion tests/operators/test_dbt_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
DbtSeedOperator,
DbtSnapshotOperator,
DbtRunOperator,
DbtTestOperator
DbtTestOperator,
DbtDepsOperator
)


Expand Down Expand Up @@ -54,3 +55,12 @@ def test_dbt_seed(self, mock_run_cli):
)
operator.execute(None)
mock_run_cli.assert_called_once_with('seed')

@mock.patch.object(DbtCliHook, 'run_cli')
def test_dbt_deps(self, mock_run_cli):
operator = DbtDepsOperator(
task_id='deps',
dag=self.dag
)
operator.execute(None)
mock_run_cli.assert_called_once_with('deps')

0 comments on commit 768c314

Please sign in to comment.