-
Notifications
You must be signed in to change notification settings - Fork 61
Add missing dbt commands #68
base: master
Are you sure you want to change the base?
Add missing dbt commands #68
Conversation
According to the reference that can be found here https://docs.getdbt.com/reference/dbt-commands
mock_dag, | ||
): | ||
"""Every operator passess down to the execution the correct dbt command""" | ||
task_id = 'test_dbt_' + '_'.join(expected_command) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flake8 complains about an extra space here
class DbtRunOperationOperator(DbtBaseOperator): | ||
@apply_defaults | ||
def __init__(self, profiles_dir=None, target=None, *args, **kwargs): | ||
super(DbtRunOperationOperator, self).__init__(profiles_dir=profiles_dir, target=target, *args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flake8 complains about too long line here
I think the I got it working by doing something like this: class DbtBaseOperator:
@apply_defaults
def __init__(self,
macro=None,
args=None,
*positional_args,
**kwargs):
super(DbtBaseOperator, self).__init__(*positional_args, **kwargs)
if args is not None and not isinstance(args, dict):
raise AirflowException('The argument "args" should be a dictionary')
self.macro = macro
self.args = args
def create_hook(self):
self.hook = DbtHook(
macro=self.macro,
args=self.args)
return self.hook
class DbtRunOperationOperator(DbtBaseOperator):
@apply_defaults
def __init__(self, profiles_dir=None, target=None, *args, **kwargs):
super(DbtRunOperationOperator, self).__init__(profiles_dir=profiles_dir, target=target, *args, **kwargs)
def execute(self, context):
self.create_hook().execute('run-operation', self.macro) And then of course adding the |
According to the DBT CLI reference there are still some missing commands.
This solves:
DbtSourceOperator
DbtBuildOperator