Skip to content

Commit

Permalink
fix: Set template fields for each operator
Browse files Browse the repository at this point in the history
DAGs do not render properly when template fields do not exist. Since we were defining `template_fields` at the base class, these may not be present in all subclasses. We moved `template_fields` to each subclass to fix this.
  • Loading branch information
tomasfarias authored Dec 6, 2021
1 parent e06caeb commit 3b65cca
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
47 changes: 44 additions & 3 deletions airflow_dbt_python/operators/dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ class DbtBaseOperator(BaseOperator):
"profiles_dir",
"profile",
"target",
"select",
"models",
"exclude",
"state",
]

Expand Down Expand Up @@ -315,6 +312,12 @@ class DbtRunOperator(DbtBaseOperator):
https://docs.getdbt.com/reference/commands/run.
"""

template_fields = DbtBaseOperator.template_fields + [
"select",
"models",
"exclude",
]

def __init__(
self,
full_refresh: Optional[bool] = None,
Expand Down Expand Up @@ -344,6 +347,11 @@ class DbtSeedOperator(DbtBaseOperator):
https://docs.getdbt.com/reference/commands/seed.
"""

template_fields = DbtBaseOperator.template_fields + [
"select",
"exclude",
]

def __init__(
self,
full_refresh: Optional[bool] = None,
Expand Down Expand Up @@ -374,6 +382,12 @@ class DbtTestOperator(DbtBaseOperator):
https://docs.getdbt.com/reference/commands/test.
"""

template_fields = DbtBaseOperator.template_fields + [
"select",
"models",
"exclude",
]

def __init__(
self,
data: Optional[bool] = None,
Expand Down Expand Up @@ -405,6 +419,12 @@ class DbtCompileOperator(DbtBaseOperator):
https://docs.getdbt.com/reference/commands/compile.
"""

template_fields = DbtBaseOperator.template_fields + [
"select",
"models",
"exclude",
]

def __init__(
self,
parse_only: Optional[bool] = None,
Expand Down Expand Up @@ -490,6 +510,11 @@ class DbtSnapshotOperator(DbtBaseOperator):
https://docs.getdbt.com/reference/commands/snapshot.
"""

template_fields = DbtBaseOperator.template_fields + [
"select",
"exclude",
]

def __init__(
self,
select: Optional[list[str]] = None,
Expand All @@ -515,6 +540,12 @@ class DbtLsOperator(DbtBaseOperator):
https://docs.getdbt.com/reference/commands/list.
"""

template_fields = DbtBaseOperator.template_fields + [
"select",
"exclude",
"resource_types",
]

def __init__(
self,
resource_types: Optional[list[str]] = None,
Expand Down Expand Up @@ -558,6 +589,11 @@ class DbtRunOperationOperator(DbtBaseOperator):
https://docs.getdbt.com/reference/commands/run-operation.
"""

template_fields = DbtBaseOperator.template_fields + [
"macro",
"args",
]

def __init__(
self,
macro: str,
Expand Down Expand Up @@ -628,6 +664,11 @@ class DbtBuildOperator(DbtBaseOperator):
https://docs.getdbt.com/reference/commands/build.
"""

template_fields = DbtBaseOperator.template_fields + [
"select",
"exclude",
]

def __init__(
self,
full_refresh: Optional[bool] = None,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "airflow-dbt-python"
version = "0.9.1"
version = "0.9.2"
description = "A dbt operator for Airflow that uses the dbt Python package"
authors = ["Tomás Farías Santana <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 3b65cca

Please sign in to comment.