Conversation
Apply Sweep Rules to your PR?
|
👷 Deploy Preview for amazing-pothos-a3bca0 processing.
|
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #599 +/- ##
==========================================
+ Coverage 93.13% 93.15% +0.02%
==========================================
Files 51 51
Lines 2053 2059 +6
==========================================
+ Hits 1912 1918 +6
Misses 141 141
☔ View full report in Codecov by Sentry. |
| if node.resource_type == DbtResourceType.MODEL: | ||
| task_args["models"] = node.name | ||
| elif node.resource_type == DbtResourceType.SOURCE: | ||
| task_args["select"] = f"source:{node.unique_id[len('source.'):]}" |
There was a problem hiding this comment.
do we have a test case that's covering this part?
There was a problem hiding this comment.
@harels, we have a unit that covers the path formation for all these variations:
test_create_test_task_metadata, and I manually played with dbt 1.6 to confirm all these variations work.
ATM, we don't have an integration test for DbtResourceType.SOURCE since our only example DAG that validates this type of node overrides any default behavior. For us to have an end-to-end version of the code going through this, Cosmos would need a default behavior for SOURCE nodes, something we don't currently have.
@harels @jlaneve Should we add a ticket to define a default behavior for Source nodes? What do you think that should look like? Should it check for freshness?
|
I'm merging since the PR was approved, and the open discussion should only be closed once we decide whether to have a follow-up ticket. |
…ER_EACH (#599) Previously Cosmos would only create a task group when using `TestBehavior.AFTER_EACH` for nodes of the type `DbtResourceType.MODEL`. This change adds the same behavior to snapshots and seeds. For this to work as expected with sources, we would need to create a default operator to handle `DbtResourceType.SOURCE`, which is outside the scope of the current ticket. Once this operator exists, sources will also lead to creating a task group. All the test selectors were tested successfully with dbt 1.6. This screenshot illustrates the validation of this feature, with an adapted version of Jaffle Shop: <img width="1502" alt="Screenshot 2023-10-13 at 19 43 52" src="https://github.com/astronomer/astronomer-cosmos/assets/272048/893ac557-1846-4ed1-b5e2-913a7bd38485"> The modifications that were done to jaffle_shop were: Appended the following lines to `dev/dags/dbt/jaffle_shop/models/schema.yml`: ``` seeds: - name: raw_customers description: Raw data from customers columns: - name: id tests: - unique - not_null snapshots: - name: orders_snapshot description: Snapshot of orders columns: - name: orders_snapshot.order_id tests: - unique - not_null ``` And created the file `dev/dags/dbt/jaffle_shop/snapshots/orders_snapshot.sql` with: ``` {% snapshot orders_snapshot %} {{ config( target_database='postgres', target_schema='public', unique_key='order_id', strategy='timestamp', updated_at='order_date', ) }} select * from {{ ref('jaffle_shop', 'orders') }} {% endsnapshot %} ``` Closes: #474 (cherry picked from commit e09ac6d)
Bug fixes * Resolve errors occurring when `dbt_project_path` is str and partial support `dbt_project_path=None` by @MrBones757 in #605 * Fix running dbt tests that depend on multiple models (support `--indirect-selection` buildable) by @david-mag in #613 * Add tests to sources, snapshots and seeds when using `TestBehavior.AFTER_EACH` by @tatiana in #599 * Fix custom selector when select has a subset of tags of the models' tags by @david-mag in #606 Others * Update contributing guide docs by @raffifu in #591 * Fix running test that validates manifest-based DAGs by @tatiana in #619 * pre-commit updates in #604 and #621
Bug fixes * Resolve errors occurring when `dbt_project_path` is str and partial support `dbt_project_path=None` by @MrBones757 in #605 * Fix running dbt tests that depend on multiple models (support `--indirect-selection` buildable) by @david-mag in #613 * Add tests to sources, snapshots and seeds when using `TestBehavior.AFTER_EACH` by @tatiana in #599 * Fix custom selector when select has a subset of tags of the models' tags by @david-mag in #606 Others * Update contributing guide docs by @raffifu in #591 * Fix running test that validates manifest-based DAGs by @tatiana in #619 * pre-commit updates in #604 and #621 (cherry picked from commit 52c34a2)
Bug fixes * Resolve errors occurring when `dbt_project_path` is str and partial support `dbt_project_path=None` by @MrBones757 in #605 * Fix running dbt tests that depend on multiple models (support `--indirect-selection` buildable) by @david-mag in #613 * Add tests to sources, snapshots and seeds when using `TestBehavior.AFTER_EACH` by @tatiana in #599 * Fix custom selector when select has a subset of tags of the models' tags by @david-mag in #606 * Fix `LoadMode.AUTOMATIC` behaviour to use `LoadMode.DBT_LS` when `ProfileMapping` is used by @tatiana in #625 * Fix failure if `openlineage-common` raises a jinja exception by @tatiana in #626 Others * Update contributing guide docs by @raffifu in #591 * Remove unnecessary stack trace from Cosmos initialization by @tatiana in #624 * Fix running test that validates manifest-based DAGs by @tatiana in #619 * pre-commit updates in #604 and #621
Bug fixes * Resolve errors occurring when `dbt_project_path` is str and partial support `dbt_project_path=None` by @MrBones757 in #605 * Fix running dbt tests that depend on multiple models (support `--indirect-selection` buildable) by @david-mag in #613 * Add tests to sources, snapshots and seeds when using `TestBehavior.AFTER_EACH` by @tatiana in #599 * Fix custom selector when select has a subset of tags of the models' tags by @david-mag in #606 * Fix `LoadMode.AUTOMATIC` behaviour to use `LoadMode.DBT_LS` when `ProfileMapping` is used by @tatiana in #625 * Fix failure if `openlineage-common` raises a jinja exception by @tatiana in #626 Others * Update contributing guide docs by @raffifu in #591 * Remove unnecessary stack trace from Cosmos initialization by @tatiana in #624 * Fix running test that validates manifest-based DAGs by @tatiana in #619 * pre-commit updates in #604 and #621 (cherry picked from commit 635fb7b)
Bug fixes * Resolve errors occurring when `dbt_project_path` is str and partial support `dbt_project_path=None` by @MrBones757 in #605 * Fix running dbt tests that depend on multiple models (support `--indirect-selection` buildable) by @david-mag in #613 * Add tests to sources, snapshots and seeds when using `TestBehavior.AFTER_EACH` by @tatiana in #599 * Fix custom selector when select has a subset of tags of the models' tags by @david-mag in #606 * Fix `LoadMode.AUTOMATIC` behaviour to use `LoadMode.DBT_LS` when `ProfileMapping` is used by @tatiana in #625 * Fix failure if `openlineage-common` raises a jinja exception by @tatiana in #626 Others * Update contributing guide docs by @raffifu in #591 * Remove unnecessary stack trace from Cosmos initialization by @tatiana in #624 * Fix running test that validates manifest-based DAGs by @tatiana in #619 * pre-commit updates in #604 and #621 (cherry picked from commit 635fb7b)
Previously Cosmos would only create a task group when using
TestBehavior.AFTER_EACHfor nodes of the typeDbtResourceType.MODEL. This change adds the same behavior to snapshots and seeds.For this to work as expected with sources, we would need to create a default operator to handle
DbtResourceType.SOURCE, which is outside the scope of the current ticket. Once this operator exists, sources will also lead to creating a task group.All the test selectors were tested successfully with dbt 1.6.
This screenshot illustrates the validation of this feature, with an adapted version of Jaffle Shop:

The modifications that were done to jaffle_shop were:
Appended the following lines to
dev/dags/dbt/jaffle_shop/models/schema.yml:And created the file
dev/dags/dbt/jaffle_shop/snapshots/orders_snapshot.sqlwith:Closes: #474