-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix running models that use alias while supporting dbt versions #662
Fix running models that use alias while supporting dbt versions #662
Conversation
👷 Deploy Preview for amazing-pothos-a3bca0 processing.
|
d5e89d2
to
ccc1dc3
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #662 +/- ##
==========================================
+ Coverage 92.76% 92.77% +0.01%
==========================================
Files 55 55
Lines 2238 2243 +5
==========================================
+ Hits 2076 2081 +5
Misses 162 162 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @binhnq94 , thank you very much for doing this work!
It is a critical part of Cosmos, and I took some time to review. I am still learning about dbt's aliasses and naming strategies - and I'm slightly concerned that this change may break users or have unintended side-effects. That said, I believe the best way will be for us to release it as part of an alpha release and collect user feedback.
Please, when you have a chance, address the comments inline - I'll be testing it with a few dbt examples and we'll aim to release this as part of an alpha 1.3 release.
@binhnq94 confirming the overall approach we are adopting after this PR: We will be naming Airflow tasks based on the model and version and no longer aliases since those were designed to reference SQL tables and not as model identifiers. When we do
When using Cosmos 1.2.0 - 1.2.4, we rendered based on the alias, which meant that When Cosmos attempted to run the dbt command, it failed to find the models with those alias-based names, although the task succeeded:
Since dbt does not recognise the alias as a model:
With the change introduced by this PR, we can render the
That matches an existing model and runs it successfully:
I'm confident with this change, and once you address the minor feedback & rebase, we can merge it into the main. Since this is a fix, we can release it in a micro release of Cosmos (e.g. 1.2.5). |
6ec9df1
to
a58b040
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this and addressing all the feedback, @binhnq94 , great work!
Bug fixes * Fix running models that use alias while supporting dbt versions by @binhnq94 in astronomer#662 * Make profiles_yml_path optional for ExecutionMode.DOCKER and KUBERNETES by @MrBones757 in astronomer#681 * Prevent overriding dbt profile fields with profile args of type or method by @jbandoro in astronomer#702 * Fix LoadMode.DBT_LS fail when dbt outputs WarnErrorOptions by @adammarples in astronomer#692 * Add support for env vars in RenderConfig for dbt ls parsing by @jbandoro in astronomer#690 * Add support for Kubernetes on_warning_callback by @david-mag in astronomer#673 * Fix ExecutionConfig.dbt_executable_path to use ``default_factory`` by @jbandoro in astronomer#678 Others * Docs fix: example DAG in the README and docs/index by @tatiana in astronomer#705 * Docs improvement: highlight DAG examples in README by @iancmoritz and @jlaneve in astronomer#695 (cherry picked from commit 2878d6a)
…onomer#662) Current version, cosmos will got bug `Not found node` because it run with alias selection as: `--models customers_abc_v1 ` and `--models customers_abc_v2` . I propose to parsing node selection in `unique_id` instead of using `alias` . So node selection should be: `unique_id.split('.', 2)[2]` , reference to [function](https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/contracts/graph/node_args.py#L26) and [resource-details document](https://docs.getdbt.com/reference/artifacts/manifest-json#resource-details). In addition, with this change help cosmos also support versioned models on dbt-core `>=1.5.0` instead `>=1.6.0` as current version. Cosmos will support dynamic aliases and versioned models Closes: astronomer#636
Bug fixes * Fix running models that use alias while supporting dbt versions by @binhnq94 in astronomer#662 * Make profiles_yml_path optional for ExecutionMode.DOCKER and KUBERNETES by @MrBones757 in astronomer#681 * Prevent overriding dbt profile fields with profile args of type or method by @jbandoro in astronomer#702 * Fix LoadMode.DBT_LS fail when dbt outputs WarnErrorOptions by @adammarples in astronomer#692 * Add support for env vars in RenderConfig for dbt ls parsing by @jbandoro in astronomer#690 * Add support for Kubernetes on_warning_callback by @david-mag in astronomer#673 * Fix ExecutionConfig.dbt_executable_path to use ``default_factory`` by @jbandoro in astronomer#678 Others * Docs fix: example DAG in the README and docs/index by @tatiana in astronomer#705 * Docs improvement: highlight DAG examples in README by @iancmoritz and @jlaneve in astronomer#695 (cherry picked from commit 2878d6a)
Description
Current version, cosmos will got bug
Not found node
because it run with alias selection as:--models customers_abc_v1
and--models customers_abc_v2
.I propose to parsing node selection in
unique_id
instead of usingalias
.So node selection should be:
unique_id.split('.', 2)[2]
, reference to function and resource-details document.In addition, with this change help cosmos also support versioned models on dbt-core
>=1.5.0
instead>=1.6.0
as current version.Related Issue(s)
closes #636
Breaking Change?
Cosmos will support dynamic alias and versioned models
Checklist