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

Loosen type on replaceable_relation and renameable_relation and provide guidance in docstrings #8647

Merged
merged 4 commits into from
Sep 14, 2023

Conversation

mikealfare
Copy link
Contributor

Problem

The typing on renameable_relations and replaceable_relations is overly prescriptive. The only requirement is that the relations in this class variable are contained in an object that defines __contains__ and that said object is immutable (frozen dataclass). Tuple and FrozenSet are both valid examples, and an adapter maintainer may prefer one or the other, or some third option.

Solution

Update the type to Iterable[str] and make updates in the methods to account for None.

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/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

@mikealfare mikealfare requested a review from a team as a code owner September 13, 2023 22:42
@mikealfare mikealfare self-assigned this Sep 13, 2023
@cla-bot cla-bot bot added the cla:yes label Sep 13, 2023
@github-actions
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.

@mikealfare mikealfare requested a review from a team as a code owner September 13, 2023 22:47
@mikealfare mikealfare requested a review from gshank September 13, 2023 22:47
@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (26c7675) 86.56% compared to head (73d6d71) 86.56%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8647   +/-   ##
=======================================
  Coverage   86.56%   86.56%           
=======================================
  Files         175      175           
  Lines       25595    25596    +1     
=======================================
+ Hits        22156    22157    +1     
  Misses       3439     3439           
Flag Coverage Δ
integration 83.35% <100.00%> (+<0.01%) ⬆️
unit 65.12% <100.00%> (+<0.01%) ⬆️

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

Files Changed Coverage Δ
core/dbt/adapters/base/relation.py 93.88% <100.00%> (+0.02%) ⬆️

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


@property
def can_be_replaced(self) -> bool:
return self.type in self.replaceable_relations
return self.type in self.replaceable_relations if self.type else False
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure we need this, if self.type is None it should evaluate to False anyways

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was appeasing the mypy overlord. However, I no longer need it since I backed off of Iterable to Union[Tuple, FrozenSet]. I did that because a general Iterable is not serializable (for mashumaro).

Copy link
Contributor

@colin-rogers-dbt colin-rogers-dbt left a comment

Choose a reason for hiding this comment

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

one nit but otherwise LGTM

@mikealfare mikealfare merged commit 3cc7044 into main Sep 14, 2023
@mikealfare mikealfare deleted the feature/materialized-views/relation-registration branch September 14, 2023 00:17
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.

2 participants