Skip to content
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

Render vars when parsing DbtModel and appending upstream_models #502

Merged
merged 17 commits into from
Sep 11, 2023

Conversation

dojinkimm
Copy link
Contributor

Description

When parsing DbtModel if I have vars in sql file, I fail to get valid upstream models (vars were not rendered as expected). This is because when add a model to upstream_models only Const types are allowed and Concat types are skipped.

-- sql file
SELECT
    column_1,
	column_2,
FROM {{ ref('stg_users_'~ var('country_code')) }} # ex) `stg_users_us` is added to upstream_models

I passed operator_args and used vars from operator_args when adding upstream_models. if variable exist but it is not defined in vars it raises KeyError and skips as before. If correct value exist for vars it the value is added up to upstream_model

Related Issue(s)

closes #495

Breaking Change?

Checklist

  • I have added tests that prove my fix is effective or that my feature works

@netlify
Copy link

netlify bot commented Aug 31, 2023

👷 Deploy Preview for amazing-pothos-a3bca0 processing.

Name Link
🔨 Latest commit d2dfec6
🔍 Latest deploy log https://app.netlify.com/sites/amazing-pothos-a3bca0/deploys/64fedc032a8970000807f3de

@dojinkimm dojinkimm temporarily deployed to external August 31, 2023 14:42 — with GitHub Actions Inactive
@dojinkimm dojinkimm marked this pull request as ready for review August 31, 2023 15:13
@dojinkimm dojinkimm requested a review from a team as a code owner August 31, 2023 15:13
@dojinkimm dojinkimm requested a review from a team August 31, 2023 15:13
@pre-commit-ci pre-commit-ci bot temporarily deployed to external September 1, 2023 01:08 Inactive
@codecov
Copy link

codecov bot commented Sep 1, 2023

Codecov Report

Patch coverage: 76.00% and project coverage change: -0.05% ⚠️

Comparison is base (74dff86) 91.82% compared to head (d2dfec6) 91.78%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #502      +/-   ##
==========================================
- Coverage   91.82%   91.78%   -0.05%     
==========================================
  Files          49       49              
  Lines        1896     1911      +15     
==========================================
+ Hits         1741     1754      +13     
- Misses        155      157       +2     
Files Changed Coverage Δ
cosmos/converter.py 95.58% <ø> (ø)
cosmos/dbt/parser/project.py 90.47% <73.91%> (-0.39%) ⬇️
cosmos/__init__.py 100.00% <100.00%> (ø)
cosmos/dbt/graph.py 98.68% <100.00%> (+<0.01%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tatiana tatiana added this to the 1.2.0 milestone Sep 11, 2023
@tatiana tatiana temporarily deployed to external September 11, 2023 09:21 — with GitHub Actions Inactive
Copy link
Collaborator

@tatiana tatiana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dojinkimm , this is looking great. Thanks for the fix and the test! Once the tests pass after the rebase, I'll merge this change. We'll release it as part of the 1.1.1 release.

Out of curiosity, why are you using load_method=LoadMode.CUSTOM?

@tatiana tatiana modified the milestones: 1.2.0, 1.1.1 Sep 11, 2023
@tatiana tatiana merged commit dd0dcb6 into astronomer:main Sep 11, 2023
@dojinkimm
Copy link
Contributor Author

dojinkimm commented Sep 11, 2023

Out of curiosity, why are you using load_method=LoadMode.CUSTOM?

@tatiana I am currently using astronomer-cosmos 0.6.8 due to some package conflicts in my environment, and load_method does not exist in that version. So, I was using default parsing logic

@tatiana
Copy link
Collaborator

tatiana commented Sep 12, 2023

Hi @dojinkimm , I see - is there any chance we could help you with the dependency conflict? Please feel free to log a ticket.
We were aiming to release this as part of 1.1.1 - and I'd love to see if we can help you move to the newer version.

tatiana added a commit that referenced this pull request Sep 14, 2023
Bug fixes

* Fix attempt of emitting OpenLineage events if task execution fails by @tatiana in #526
* Fix Rust dependency for Windows users by @tatiana in #526
* Fix DbtRunOperationLocalOperator missing flags by @tatiana in #529
* Fix DbtRunLocalOperator to support the full refresh argument by @tatiana in #529
* Remove redundant prefix of task names when test_behavior = TestBehavior.AFTER_EACH by @binhnq94 in #524
* Fix rendering vars in `DbtModel` when using `LoadMode.CUSTOM` by @dojinkimm in #502

Others

* Docs: add `documentation comparing Airflow and dbt concepts <https://astronomer.github.io/astronomer-cosmos/getting_started/dbt-airflow-concepts.html>`_ by @tatiana in #523.
* Update PyPI project links by @tatiana in #528
* pre-commit updates
tatiana added a commit that referenced this pull request Sep 14, 2023
Bug fixes

* Fix attempt of emitting OpenLineage events if task execution fails by @tatiana in #526
* Fix Rust dependency for Windows users by @tatiana in #526
* Fix DbtRunOperationLocalOperator missing flags by @tatiana in #529
* Fix DbtRunLocalOperator to support the full refresh argument by @tatiana in #529
* Remove redundant prefix of task names when test_behavior = TestBehavior.AFTER_EACH by @binhnq94 in #524
* Fix rendering vars in `DbtModel` when using `LoadMode.CUSTOM` by @dojinkimm in #502

Others

* Docs: add `documentation comparing Airflow and dbt concepts <https://astronomer.github.io/astronomer-cosmos/getting_started/dbt-airflow-concepts.html>`_ by @tatiana in #523.
* Update PyPI project links by @tatiana in #528
* pre-commit updates
@tatiana tatiana mentioned this pull request Sep 14, 2023
harels pushed a commit that referenced this pull request Sep 14, 2023
Bug fixes

* Remove redundant prefix of task names when test_behavior =
TestBehavior.AFTER_EACH by @binhnq94 in #524
* Fix rendering vars in `DbtModel` when using `LoadMode.CUSTOM` by
@dojinkimm in #502
* Fix attempt of emitting OpenLineage events if task execution fails by
@tatiana in #526
* Fix Rust dependency for Windows users by @tatiana in #526
* Fix DbtRunOperationLocalOperator missing flags by @tatiana in #529
* Fix DbtRunLocalOperator to support the full refresh argument by
@tatiana in #529

Others

* Docs: add `documentation comparing Airflow and dbt concepts
<https://astronomer.github.io/astronomer-cosmos/getting_started/dbt-airflow-concepts.html>`_
by @tatiana in #523.
* Update PyPI project links by @tatiana in #528
* pre-commit updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Render vars when parsing DbtModel
2 participants