-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
spike: inferred contracts #8339
base: main
Are you sure you want to change the base?
Conversation
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. |
1 similar comment
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. |
Codecov Report
@@ Coverage Diff @@
## main #8339 +/- ##
==========================================
- Coverage 86.35% 79.66% -6.69%
==========================================
Files 174 174
Lines 25573 25577 +4
==========================================
- Hits 22083 20376 -1707
- Misses 3490 5201 +1711
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Not as bad as I thought! Now we just need to think through, is it something we actually want?
# TODO: avoid routing on args.which if possible | ||
if getattr(self.model, "defer_relation", None) and self.config.args.which == "clone": |
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.
Definitely want to avoid the need for this. I had previously wondered if we'd be able to consolidate the deferral methods used by clone
and other commands, by:
- clobbering unselected resources with the production versions (to support "traditional" deferral)
- adding
defer_relation
for selected resources only (to supportclone
)
(this comment/issue: #7965)
Edit: Michelle already made this change below. Then we can also refactor the clone
task to use merge_from_artifact
, and delete add_from_artifact
.
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.
Discussing live with @MichelleArk: We should overwrite compiled_code
(also aliased as sql
) within the clone
task. Then we don't need to have this task-aware conditional logic live in the context method.
{% set prod_columns = get_column_schema_from_query(get_empty_subquery_sql("select * from " ~ defer_relation)) %} | ||
{% set raw_columns = {} %} | ||
{% for column in prod_columns -%} | ||
{# TODO: reconsider this mutating operation, could be done with an additional warehouse call #} |
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.
👍 At minimum, we should probably be deepcopying to avoid mutating the user-provided value stored in the context... right?
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.
We can either:
- plumb it through (but this takes some time, and tightly couples the methods)
- make the warehouse call twice (and consider caching/optimization possibilities in the future)
Ah, I knew I'd been forgetting something. From the issue:
I think this is two things. (1) Adding new columnsRight now, to add a column to a model with an inferred contract, you need to explicitly define its name + data type. Otherwise, you get a
I think we have two options:
(2) Detecting breaking changesWe also need to update our logic for detecting
|
resolves #7432
docs dbt-labs/docs.getdbt.com/#
Problem
Solution
Checklist
🎩
model.sql
schema.yml
👟
enforced: false
(& optionally commentcolumns
out)dbt run
to create a prod version of the modelenforced: true
(& optionally commentcolumns
back in)dbt run --defer --state target/