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

Enable sql_header within generic data tests #9854

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/dbt/artifacts/resources/v1/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class TestConfig(NodeAndTestConfig):
severity: Annotated[Severity, Pattern(SEVERITY_PATTERN)] = Severity("ERROR")
store_failures: Optional[bool] = None
store_failures_as: Optional[str] = None
sql_header: Optional[str] = None
where: Optional[str] = None
limit: Optional[int] = None
fail_calc: str = "count(*)"
Expand Down Expand Up @@ -237,6 +238,7 @@ def same_contents(cls, unrendered: Dict[str, Any], other: Dict[str, Any]) -> boo
"error_if",
"store_failures",
"store_failures_as",
"sql_header",
]

seen = set()
Expand Down
7 changes: 7 additions & 0 deletions core/dbt/parser/generic_test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"fail_calc",
"store_failures",
"store_failures_as",
"sql_header",
"meta",
"database",
"schema",
Expand Down Expand Up @@ -248,6 +249,10 @@
def store_failures_as(self) -> Optional[bool]:
return self.config.get("store_failures_as")

@property
def sql_header(self) -> Optional[str]:
return self.config.get("sql_header")

@property
def where(self) -> Optional[str]:
return self.config.get("where")
Expand Down Expand Up @@ -302,6 +307,8 @@
config["store_failures"] = self.store_failures
if self.store_failures_as is not None:
config["store_failures_as"] = self.store_failures_as
if self.sql_header is not None:
config["sql_header"] = self.sql_header

Check warning on line 311 in core/dbt/parser/generic_test_builders.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/parser/generic_test_builders.py#L311

Added line #L311 was not covered by tests
if self.meta is not None:
config["meta"] = self.meta
if self.database is not None:
Expand Down