-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Misc fixes for group info in logging (#11218)
- Loading branch information
Showing
11 changed files
with
374 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Under the Hood | ||
body: Misc fixes for group info in logging | ||
time: 2025-01-17T15:22:15.497485Z | ||
custom: | ||
Author: aranke | ||
Issue: '11218' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
from dataclasses import dataclass | ||
from typing import Optional | ||
from typing import List, Optional, Union | ||
|
||
from dbt_common.contracts.config.properties import AdditionalPropertiesAllowed | ||
|
||
|
||
@dataclass | ||
class Owner(AdditionalPropertiesAllowed): | ||
email: Optional[str] = None | ||
email: Union[str, List[str], None] = None | ||
name: Optional[str] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,27 @@ def test_invalid_event_value(project, logs_dir): | |
access: public | ||
""" | ||
|
||
groups_yml_with_multiple_emails = """ | ||
groups: | ||
- name: my_group_with_multiple_emails | ||
owner: | ||
name: my_name | ||
email: | ||
- [email protected] | ||
- [email protected] | ||
slack: my_slack | ||
other_property: something_else | ||
models: | ||
- name: my_model | ||
group: my_group_with_multiple_emails | ||
access: public | ||
columns: | ||
- name: my_column | ||
tests: | ||
- not_null | ||
""" | ||
|
||
|
||
class TestRunResultErrorNodeInfo: | ||
@pytest.fixture(scope="class") | ||
|
@@ -289,3 +310,41 @@ def models(self): | |
def test_node_info_on_results(self, project, logs_dir): | ||
results = run_dbt(["--no-write-json", "run"]) | ||
assert len(results) == 1 | ||
|
||
|
||
class TestRunResultGroupWithMultipleEmails: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"my_model.sql": "select 1 as id, null as my_column", | ||
"groups.yml": groups_yml_with_multiple_emails, | ||
} | ||
|
||
def test_node_info_on_results(self, project, logs_dir): | ||
results = run_dbt(["--log-format=json", "build"], expect_pass=False) | ||
assert len(results) == 2 | ||
|
||
log_file = read_file(logs_dir, "dbt.log") | ||
run_result_error_count = 0 | ||
|
||
for log_line in log_file.split("\n"): | ||
if not log_line: | ||
continue | ||
|
||
log_json = json.loads(log_line) | ||
if log_json["info"]["level"] == EventLevel.DEBUG: | ||
continue | ||
|
||
if log_json["info"]["name"] == "RunResultError": | ||
assert "group" in log_json["data"] | ||
group_data = log_json["data"]["group"] | ||
assert group_data["name"] == "my_group_with_multiple_emails" | ||
assert group_data["owner"] == { | ||
"name": "my_name", | ||
"email": "['[email protected]', '[email protected]']", | ||
"slack": "my_slack", | ||
"other_property": "something_else", | ||
} | ||
run_result_error_count += 1 | ||
|
||
assert run_result_error_count == 1 |