From c2124aa277f31934a37504425060b8152c8b076c Mon Sep 17 00:00:00 2001 From: pankajastro Date: Thu, 27 Feb 2025 22:59:00 +0530 Subject: [PATCH 1/4] Enable DAG _example_cosmos_dbt_build.py --- .github/workflows/test.yml | 2 +- dev/dags/dbt/altered_jaffle_shop/macros/drop_table.sql | 6 ------ tests/test_example_dags.py | 3 --- 3 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 dev/dags/dbt/altered_jaffle_shop/macros/drop_table.sql diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 475090f5c..0837a6527 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: test on: push: # Run on pushes to the default branch - branches: [main] + branches: [main, fix_example_cosmos_dbt_build] pull_request_target: # Also run on pull requests originated from forks branches: [main] diff --git a/dev/dags/dbt/altered_jaffle_shop/macros/drop_table.sql b/dev/dags/dbt/altered_jaffle_shop/macros/drop_table.sql deleted file mode 100644 index 37a8b21d7..000000000 --- a/dev/dags/dbt/altered_jaffle_shop/macros/drop_table.sql +++ /dev/null @@ -1,6 +0,0 @@ -{%- macro drop_table_by_name(table_name) -%} - {%- set drop_query -%} - DROP TABLE IF EXISTS {{ target.schema }}.{{ table_name }} CASCADE - {%- endset -%} - {% do run_query(drop_query) %} -{%- endmacro -%} diff --git a/tests/test_example_dags.py b/tests/test_example_dags.py index d85881279..762985b59 100644 --- a/tests/test_example_dags.py +++ b/tests/test_example_dags.py @@ -81,9 +81,6 @@ def get_dag_bag() -> DagBag: if DBT_VERSION < Version("1.5.0"): file.writelines(["example_source_rendering.py\n"]) - # TODO: Fix https://github.com/astronomer/astronomer-cosmos/issues/1568 - file.writelines("example_cosmos_dbt_build.py\n") - print(".airflowignore contents: ") print(AIRFLOW_IGNORE_FILE.read_text()) db = DagBag(EXAMPLE_DAGS_DIR, include_examples=False) From 597d88d65000af19f0544a4da807c2bd37ecaed6 Mon Sep 17 00:00:00 2001 From: pankajastro Date: Thu, 27 Feb 2025 23:21:13 +0530 Subject: [PATCH 2/4] Run tests for AF > 2.7 --- tests/test_example_dags.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_example_dags.py b/tests/test_example_dags.py index 762985b59..d0671ec95 100644 --- a/tests/test_example_dags.py +++ b/tests/test_example_dags.py @@ -81,6 +81,9 @@ def get_dag_bag() -> DagBag: if DBT_VERSION < Version("1.5.0"): file.writelines(["example_source_rendering.py\n"]) + if AIRFLOW_VERSION < Version("2.8.0"): + file.writelines("example_cosmos_dbt_build.py\n") + print(".airflowignore contents: ") print(AIRFLOW_IGNORE_FILE.read_text()) db = DagBag(EXAMPLE_DAGS_DIR, include_examples=False) From 9fcfcaacf4256d022737939cec896eceabf0e499 Mon Sep 17 00:00:00 2001 From: pankajastro Date: Thu, 27 Feb 2025 23:34:51 +0530 Subject: [PATCH 3/4] restore macros --- dev/dags/dbt/altered_jaffle_shop/macros/drop_table.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 dev/dags/dbt/altered_jaffle_shop/macros/drop_table.sql diff --git a/dev/dags/dbt/altered_jaffle_shop/macros/drop_table.sql b/dev/dags/dbt/altered_jaffle_shop/macros/drop_table.sql new file mode 100644 index 000000000..37a8b21d7 --- /dev/null +++ b/dev/dags/dbt/altered_jaffle_shop/macros/drop_table.sql @@ -0,0 +1,6 @@ +{%- macro drop_table_by_name(table_name) -%} + {%- set drop_query -%} + DROP TABLE IF EXISTS {{ target.schema }}.{{ table_name }} CASCADE + {%- endset -%} + {% do run_query(drop_query) %} +{%- endmacro -%} From bf9d35405d911efdd2c73f60ce301ee4cfa0f8ab Mon Sep 17 00:00:00 2001 From: Pankaj Singh <98807258+pankajastro@users.noreply.github.com> Date: Thu, 27 Feb 2025 23:37:36 +0530 Subject: [PATCH 4/4] Update .github/workflows/test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0837a6527..475090f5c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: test on: push: # Run on pushes to the default branch - branches: [main, fix_example_cosmos_dbt_build] + branches: [main] pull_request_target: # Also run on pull requests originated from forks branches: [main]