Skip to content

Commit 127dfc9

Browse files
committed
docs: Add documentation for dbt operators
1 parent d5dc5a3 commit 127dfc9

File tree

1 file changed

+81
-15
lines changed
  • airflow_dbt_python/operators

1 file changed

+81
-15
lines changed

airflow_dbt_python/operators/dbt.py

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,14 @@ def __init__(
9595
self._dbt_s3_hook = None
9696

9797
def execute(self, context: dict):
98-
"""Execute dbt command with prepared arguments."""
98+
"""Execute dbt command with prepared arguments.
99+
100+
Execution requires setting up a directory with the dbt project files and
101+
overriding the logging.
102+
103+
Args:
104+
context: The Airflow's task context
105+
"""
99106
with self.dbt_directory() as dbt_dir: # type: str
100107
with self.override_dbt_logging(dbt_dir):
101108
args = self.prepare_args()
@@ -125,6 +132,9 @@ def execute(self, context: dict):
125132
def xcom_push_artifacts(self, context: dict, dbt_directory: str):
126133
"""Read dbt artifacts and push them to XCom.
127134
135+
Artifacts are read from the target/ directory in dbt_directory. This method will
136+
fail if the required artifact is not found.
137+
128138
Args:
129139
context: The Airflow task's context.
130140
dbt_directory: A directory containing a dbt project. Artifacts will be
@@ -160,7 +170,11 @@ def prepare_args(self) -> list[Optional[str]]:
160170
return args
161171

162172
def args_list(self) -> list[str]:
163-
"""Build a list of arguments to pass to dbt."""
173+
"""Build a list of arguments to pass to dbt.
174+
175+
Building involves creating a list of flags for dbt to parse given the operators
176+
attributes and the values specified by __dbt_args__.
177+
"""
164178
args = []
165179
for arg in self.__dbt_args__:
166180
value = getattr(self, arg, None)
@@ -289,7 +303,12 @@ def serializable_result(
289303

290304

291305
class DbtRunOperator(DbtBaseOperator):
292-
"""Executes dbt run."""
306+
"""Executes a dbt run command.
307+
308+
The run command executes SQL model files against the given target. The
309+
documentation for the dbt command can be found here:
310+
https://docs.getdbt.com/reference/commands/run.
311+
"""
293312

294313
command = "run"
295314

@@ -337,7 +356,12 @@ def __init__(
337356

338357

339358
class DbtSeedOperator(DbtBaseOperator):
340-
"""Executes dbt seed."""
359+
"""Executes a dbt seed command.
360+
361+
The seed command loads csv files into the the given target. The
362+
documentation for the dbt command can be found here:
363+
https://docs.getdbt.com/reference/commands/seed.
364+
"""
341365

342366
command = "seed"
343367

@@ -373,7 +397,12 @@ def __init__(
373397

374398

375399
class DbtTestOperator(DbtBaseOperator):
376-
"""Executes dbt test."""
400+
"""Executes a dbt test command.
401+
402+
The test command runs data and/or schema tests. The
403+
documentation for the dbt command can be found here:
404+
https://docs.getdbt.com/reference/commands/test.
405+
"""
377406

378407
command = "test"
379408

@@ -424,7 +453,12 @@ def __init__(
424453

425454

426455
class DbtCompileOperator(DbtBaseOperator):
427-
"""Executes dbt compile."""
456+
"""Executes a dbt compile command.
457+
458+
The compile command generates SQL files. The
459+
documentation for the dbt command can be found here:
460+
https://docs.getdbt.com/reference/commands/compile.
461+
"""
428462

429463
command = "compile"
430464

@@ -469,7 +503,11 @@ def __init__(
469503

470504

471505
class DbtDepsOperator(DbtBaseOperator):
472-
"""Executes dbt deps."""
506+
"""Executes a dbt deps command.
507+
508+
The documentation for the dbt command can be found here:
509+
https://docs.getdbt.com/reference/commands/deps.
510+
"""
473511

474512
command = "deps"
475513

@@ -478,7 +516,11 @@ def __init__(self, **kwargs) -> None:
478516

479517

480518
class DbtCleanOperator(DbtBaseOperator):
481-
"""Executes dbt clean."""
519+
"""Executes a dbt clean command.
520+
521+
The documentation for the dbt command can be found here:
522+
https://docs.getdbt.com/reference/commands/debug.
523+
"""
482524

483525
command = "clean"
484526

@@ -487,7 +529,11 @@ def __init__(self, **kwargs) -> None:
487529

488530

489531
class DbtDebugOperator(DbtBaseOperator):
490-
"""Execute dbt debug."""
532+
"""Executes a dbt debug command.
533+
534+
The documentation for the dbt command can be found here:
535+
https://docs.getdbt.com/reference/commands/debug.
536+
"""
491537

492538
command = "debug"
493539

@@ -505,7 +551,11 @@ def __init__(
505551

506552

507553
class DbtSnapshotOperator(DbtBaseOperator):
508-
"""Execute dbt snapshot."""
554+
"""Executes a dbt snapshot command.
555+
556+
The documentation for the dbt command can be found here:
557+
https://docs.getdbt.com/reference/commands/snapshot.
558+
"""
509559

510560
command = "snapshot"
511561

@@ -535,7 +585,11 @@ def __init__(
535585

536586

537587
class DbtLsOperator(DbtBaseOperator):
538-
"""Execute dbt list (or ls)."""
588+
"""Executes a dbt list (or ls) command.
589+
590+
The documentation for the dbt command can be found here:
591+
https://docs.getdbt.com/reference/commands/list.
592+
"""
539593

540594
command = "ls"
541595

@@ -572,7 +626,11 @@ def __init__(
572626

573627

574628
class DbtRunOperationOperator(DbtBaseOperator):
575-
"""Execute dbt run-operation."""
629+
"""Executes a dbt run-operation command.
630+
631+
The documentation for the dbt command can be found here:
632+
https://docs.getdbt.com/reference/commands/run-operation.
633+
"""
576634

577635
command = "run-operation"
578636

@@ -591,7 +649,11 @@ def __init__(
591649

592650

593651
class DbtParseOperator(DbtBaseOperator):
594-
"""Execute dbt parse."""
652+
"""Executes a dbt parse command.
653+
654+
The documentation for the dbt command can be found here:
655+
https://docs.getdbt.com/reference/commands/parse.
656+
"""
595657

596658
command = "parse"
597659

@@ -603,7 +665,11 @@ def __init__(
603665

604666

605667
class DbtSourceOperator(DbtBaseOperator):
606-
"""Execute dbt source."""
668+
"""Executes a dbt source command.
669+
670+
The documentation for the dbt command can be found here:
671+
https://docs.getdbt.com/reference/commands/source.
672+
"""
607673

608674
command = "source"
609675

@@ -640,7 +706,7 @@ def __init__(
640706

641707

642708
class DbtBuildOperator(DbtBaseOperator):
643-
"""Execute dbt build.
709+
"""Executes a dbt build command.
644710
645711
The build command combines the run, test, seed, and snapshot commands into one. The
646712
full Documentation for the dbt build command can be found here:

0 commit comments

Comments
 (0)