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

[state:modified] persist unrendered_config from schema.yml, and more reliably compute unrendered_config from .sql files #10487

Merged
merged 29 commits into from
Sep 26, 2024

Conversation

MichelleArk
Copy link
Contributor

@MichelleArk MichelleArk commented Jul 26, 2024

Resolves #9564

Problem

  1. A node's unrendered_config included rendered values, because the population of unrendered_config from models with config in .sql files was occurring after kwargs were evaluated by value (e.g. materialized=(jinja expression) => jinja expression evaluated by the time we are in ConfigProviders)

  2. We were not storing the unrendered_configs from schema.yml parsing

Solution

All behind the new behaviour flag, state_modified_compare_more_unrendered_values

  1. Parse the unrendered_config on the node from .sql from the raw model code and store values as string representations of jinja calls
    • multiple config calls are merged naively, since we only have string types in the values
  2. Store unrendered_config on the schema file under manifest.file
    • storage under schema.yml key (e.g. "models") -> name (versioned names have _v{version} suffixes
  3. During node parsing, look up the unrendered_configs from the schema file and use them as the patch_config_dict

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 Jul 26, 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 Jul 26, 2024

Codecov Report

Attention: Patch coverage is 95.95960% with 4 lines in your changes missing coverage. Please review.

Project coverage is 89.09%. Comparing base (1fd4d2e) to head (5b0bce0).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10487      +/-   ##
==========================================
+ Coverage   89.03%   89.09%   +0.06%     
==========================================
  Files         182      182              
  Lines       23195    23288      +93     
==========================================
+ Hits        20651    20748      +97     
+ Misses       2544     2540       -4     
Flag Coverage Δ
integration 86.31% <95.95%> (+0.07%) ⬆️
unit 62.22% <69.69%> (+0.03%) ⬆️

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

Components Coverage Δ
Unit Tests 62.22% <69.69%> (+0.03%) ⬆️
Integration Tests 86.31% <95.95%> (+0.07%) ⬆️

@MichelleArk MichelleArk force-pushed the state-modified-source-tests branch from 77edf79 to bad6b92 Compare September 4, 2024 20:57
@MichelleArk MichelleArk added the artifact_minor_upgrade To bypass the CI check by confirming that the change is not breaking label Sep 5, 2024
@MichelleArk
Copy link
Contributor Author

Corresponding schemas PR: dbt-labs/schemas.getdbt.com#60

relation_name: Optional[str] = None
raw_code: str = ""

def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
if context and context.get("artifact") and "config_call_dict" in dct:
del dct["config_call_dict"]
if context and context.get("artifact") and "unrendered_config_call_dict" in dct:
del dct["unrendered_config_call_dict"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

even though this isn't serialized, we still need a schemas.getdbt.com PR, similar to config_call_dict: dbt-labs/schemas.getdbt.com#60

@MichelleArk MichelleArk changed the title persist schema yml unrendered_config before rendering [state:modified] persist schema yml unrendered_config before rendering Sep 25, 2024
core/dbt/parser/base.py Outdated Show resolved Hide resolved
@MichelleArk MichelleArk changed the title [state:modified] persist schema yml unrendered_config before rendering [state:modified] persist unrendered_config from schema.yml, and more reliably compute unrendered_config from .sql files Sep 25, 2024
@MichelleArk MichelleArk marked this pull request as ready for review September 26, 2024 11:41
@MichelleArk MichelleArk requested a review from a team as a code owner September 26, 2024 11:41
@MichelleArk MichelleArk requested a review from gshank September 26, 2024 11:41
Copy link
Contributor

@gshank gshank left a comment

Choose a reason for hiding this comment

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

It would be really nice to spend some time making all the config application and merging code cleaner. Maybe next quarter...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
artifact_minor_upgrade To bypass the CI check by confirming that the change is not breaking cla:yes
Projects
None yet
2 participants