-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d44c091
commit d4a0e20
Showing
6 changed files
with
53 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import argparse | ||
|
||
from opendbt import OpenDbtCli | ||
|
||
|
||
def main(): | ||
p = argparse.ArgumentParser() | ||
_, args = p.parse_known_args() | ||
OpenDbtCli.run(args=args) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ with source_data as ( | |
|
||
select 1 as id | ||
union all | ||
select null as id | ||
select 2 as id | ||
|
||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from pathlib import Path | ||
from unittest import TestCase | ||
|
||
from airflow import DAG | ||
from airflow.operators.empty import EmptyOperator | ||
from airflow.utils.dates import days_ago | ||
|
||
from opendbt.airflow import OpenDbtAirflowProject | ||
|
||
|
||
class TestOpenDbtProject(TestCase): | ||
RESOURCES_DIR = Path(__file__).parent.joinpath("resources") | ||
DBTTEST_DIR = RESOURCES_DIR.joinpath("dbttest") | ||
TEST_DAG = DAG( | ||
dag_id='dbt_test_workflow', | ||
schedule_interval=None, | ||
start_date=days_ago(3), | ||
catchup=False, | ||
max_active_runs=1 | ||
) | ||
|
||
def test_run_dbt_as_airflow_task(self): | ||
with self.TEST_DAG as dag: | ||
# load dbt jobs to airflow dag | ||
start = EmptyOperator(task_id="start") | ||
end = EmptyOperator(task_id="end") | ||
p = OpenDbtAirflowProject(project_dir=self.DBTTEST_DIR, profiles_dir=self.DBTTEST_DIR, target='dev') | ||
p.load_dbt_tasks(dag=dag, start_node=start, end_node=end, include_singular_tests=True, | ||
include_dbt_seeds=True) | ||
|
||
for j in dag.tasks: | ||
# run all dbt tasks trough airflow operator | ||
j.execute({}) |