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

Microbatch: store model context var as dict, not ModelNode #10917

Merged
merged 4 commits into from
Oct 28, 2024

Conversation

MichelleArk
Copy link
Contributor

@MichelleArk MichelleArk commented Oct 24, 2024

Resolves: #10927
Resolves: dbt-labs/dbt-bigquery#1376

Problem

We were erroneously updating the model jinja context variable to be of type ModelNode after re-compiling the microbatch model, when it should have been a dict. This was causing downstream issues in jinja when attempted to be accessed as a dict (e.g. not iterable, no get method).

Solution

  • model.to_dict()
  • Refactor microbatch jinja context building into MicrobatchBuilder to centralize where context is being updated + ease of testing.

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.
  • This PR includes type annotations for new and modified functions.

@cla-bot cla-bot bot added the cla:yes label Oct 24, 2024
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.14%. Comparing base (d07bfda) to head (d685226).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10917      +/-   ##
==========================================
- Coverage   89.17%   89.14%   -0.03%     
==========================================
  Files         183      183              
  Lines       23464    23473       +9     
==========================================
+ Hits        20924    20926       +2     
- Misses       2540     2547       +7     
Flag Coverage Δ
integration 86.43% <100.00%> (-0.03%) ⬇️
unit 62.08% <62.50%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Unit Tests 62.08% <62.50%> (+0.02%) ⬆️
Integration Tests 86.43% <100.00%> (-0.03%) ⬇️

@MichelleArk MichelleArk changed the title store model.to_dict in batch jinja context var of Microbatch: store model context var as dict, not ModelNode Oct 28, 2024
@MichelleArk MichelleArk marked this pull request as ready for review October 28, 2024 19:39
@MichelleArk MichelleArk requested a review from a team as a code owner October 28, 2024 19:39
Copy link
Contributor

@QMalcolm QMalcolm left a comment

Choose a reason for hiding this comment

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

🚀 LGTM

@MichelleArk MichelleArk merged commit b71ceb3 into main Oct 28, 2024
61 of 62 checks passed
@MichelleArk MichelleArk deleted the fix-batched-model-context-var branch October 28, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Microbatch: 'model' context variable is of ModelNode type instead of dict [Bug] Microbatch error
2 participants