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

add deprecation decorator #6540

Merged
merged 3 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .changes/unreleased/Breaking Changes-20221205-141937.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ body: Cleaned up exceptions to directly raise in code. Removed use of all excep
time: 2022-12-05T14:19:37.863032-06:00
custom:
Author: emmyoop
Issue: "6339"
PR: "6347"
Issue: 6339 6393
4 changes: 3 additions & 1 deletion core/dbt/context/exceptions_jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def missing_config(model, name) -> NoReturn:


def missing_materialization(model, adapter_type) -> NoReturn:
raise MissingMaterialization(model=model, adapter_type=adapter_type)
raise MissingMaterialization(
materialization=model.config.materialized, adapter_type=adapter_type
)


def missing_relation(relation, model=None) -> NoReturn:
Expand Down
11 changes: 11 additions & 0 deletions core/dbt/events/proto_types.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions core/dbt/events/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ message ExposureNameDeprecation {
string exposure = 2;
}

//D008
message FunctionDeprecated {
EventInfo info = 1;
string function_name = 2;
string reason = 3;
string suggested_action = 4;
string version = 5;
}

// E - DB Adapter

// E001
Expand Down
16 changes: 16 additions & 0 deletions core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,22 @@ def message(self):
return line_wrap_message(warning_tag(f"Deprecated functionality\n\n{description}"))


@dataclass
class FunctionDeprecated(WarnLevel, pt.FunctionDeprecated):
def code(self):
return "D008"

def message(self):
extra_reason = ""
if self.reason:
extra_reason = f"\n{self.reason}"
msg = (
f"`{self.function_name}` is deprecated and will be removed in dbt-core version {self.version}\n\n"
f"Adapter maintainers can resolve this deprecation by {self.suggested_action}. {extra_reason}"
)
return warning_tag(msg)


# =======================================================
# E - DB Adapter
# =======================================================
Expand Down
Loading