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

Er/3899 models key mismatch #3959

Merged
merged 12 commits into from
Oct 1, 2021
Merged

Er/3899 models key mismatch #3959

merged 12 commits into from
Oct 1, 2021

Conversation

emmyoop
Copy link
Member

@emmyoop emmyoop commented Sep 27, 2021

resolves # 3899

Description

Give a warning when a node is specified under the wrong type in schema.yml and don't continue processing.

Does this still need to be handled - I couldn't produce the behavior: Throw an exception for any model/seed/snapshot that has a unique_id of None and is not disabled.

As part of this change manifest._disabled was also removed in favor of the existing manifest.disabled.

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt next" section.

@cla-bot cla-bot bot added the cla:yes label Sep 27, 2021
@emmyoop emmyoop linked an issue Sep 29, 2021 that may be closed by this pull request
@emmyoop emmyoop force-pushed the er/3899-models-key-mismatch branch from a68b5d7 to 26a30a4 Compare September 29, 2021 21:12
@emmyoop emmyoop requested review from gshank and jtcohen6 September 29, 2021 21:18
@emmyoop emmyoop marked this pull request as ready for review September 29, 2021 21:18
@emmyoop emmyoop force-pushed the er/3899-models-key-mismatch branch from 26a30a4 to 8ee43df Compare September 30, 2021 13:46
Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

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

Nice work pulling on the thread for this one. I left a few small comments

core/dbt/parser/schemas.py Outdated Show resolved Hide resolved
core/dbt/parser/schemas.py Outdated Show resolved Hide resolved
@emmyoop emmyoop force-pushed the er/3899-models-key-mismatch branch from 8ee43df to 7b16b88 Compare September 30, 2021 20:56
core/dbt/exceptions.py Outdated Show resolved Hide resolved
core/dbt/exceptions.py Show resolved Hide resolved
core/dbt/exceptions.py Outdated Show resolved Hide resolved
core/dbt/exceptions.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

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

Nice work! Feels really close

self._disabled[node.unique_id].append(node)
else:
self._disabled[node.unique_id] = [node]
self.disabled.append(node)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's changed here? Are we no longer patching properties for disabled nodes?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we've ever patched disabled nodes. That's the way that it worked when I first saw it anyway.

Copy link
Contributor

@gshank gshank Oct 1, 2021

Choose a reason for hiding this comment

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

I'm not sure that feels right though. I woud have no objection to patching disabled nodes. They do come out in the manifest.json.

Copy link
Contributor

Choose a reason for hiding this comment

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

But a lookup won't find them (since they're not included there), so we'd have to separately look them up in disabled.

@@ -567,7 +567,6 @@ class Manifest(MacroMethods, DataClassMessagePackMixin, dbtClassMixin):
# Moved from the ParseResult object
source_patches: MutableMapping[SourceKey, SourcePatch] = field(default_factory=dict)
# following is from ParseResult
_disabled: MutableMapping[str, List[CompileResultNode]] = field(default_factory=dict)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove the list form of disabled, and switch to a dictionary (MutableMapping) form. (I'm not sure why this one says [str, List..]. I don't see why it would ever be an actual list, there should only be one node per unique_id). That's more in keeping with the other stored nodes ('nodes', 'macros', etc). That would involve remove the current 'disabled' from the Manifest, and renaming '_disabled' to 'disabled'. (And fixing the definition.) So in the places where a node is added to the disabled list, you'd need to add it to the dictionary.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jtcohen6 Disabled does show up in manifest.json, so this would be a manifest schema change. Do you agree with what I propose here? If we're going to do it, for 1.0 is the right time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Your proposal makes sense to me! We should feel well within our rights to make these kind of schema changes ahead of 1.0

self._disabled[node.unique_id].append(node)
else:
self._disabled[node.unique_id] = [node]
self.disabled.append(node)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we've ever patched disabled nodes. That's the way that it worked when I first saw it anyway.

@emmyoop emmyoop requested a review from gshank October 1, 2021 19:30
@emmyoop emmyoop force-pushed the er/3899-models-key-mismatch branch from 4f5006f to 332d23c Compare October 1, 2021 21:06
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.

Looks good!

@emmyoop emmyoop merged commit 8ae232a into develop Oct 1, 2021
@emmyoop emmyoop deleted the er/3899-models-key-mismatch branch October 1, 2021 21:36
jtcohen6 added a commit to dbt-labs/dbt-redshift that referenced this pull request Oct 2, 2021
jtcohen6 added a commit to dbt-labs/dbt-redshift that referenced this pull request Oct 2, 2021
jtcohen6 added a commit to dbt-labs/dbt-redshift that referenced this pull request Oct 2, 2021
abbywh pushed a commit to abbywh/dbt-redshift that referenced this pull request Oct 11, 2023
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.

Enable deprecation: models-key-mismatch
3 participants