Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 68a9d72

Browse files
authored
Merge pull request #497 from dlawin/tabulate_for_rows_added_removed
cleaner rows added/removed
2 parents 19fc965 + f71c6c5 commit 68a9d72

4 files changed

Lines changed: 22 additions & 8 deletions

File tree

data_diff/utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import operator
66
import threading
77
from datetime import datetime
8+
from tabulate import tabulate
89

910

1011
def safezip(*args):
@@ -132,12 +133,9 @@ def __repr__(self) -> str:
132133
def dbt_diff_string_template(
133134
rows_added: str, rows_removed: str, rows_updated: str, rows_unchanged: str, extra_info_dict: Dict, extra_info_str
134135
) -> str:
135-
string_output = "\n| Rows Added\t| Rows Removed\n"
136-
string_output += "------------------------------------------------------------\n"
136+
string_output = f"\n{tabulate([[rows_added, rows_removed]], headers=['Rows Added', 'Rows Removed'])}"
137137

138-
string_output += f"| {rows_added}\t\t| {rows_removed}\n"
139-
string_output += "------------------------------------------------------------\n\n"
140-
string_output += f"Updated Rows: {rows_updated}\n"
138+
string_output += f"\n\nUpdated Rows: {rows_updated}\n"
141139
string_output += f"Unchanged Rows: {rows_unchanged}\n\n"
142140

143141
string_output += extra_info_str

poetry.lock

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ duckdb = {version="^0.7.0", optional=true}
4444
dbt-artifacts-parser = {version="^0.2.5", optional=true}
4545
dbt-core = {version="^1.0.0", optional=true}
4646
keyring = "*"
47+
tabulate = "^0.9.0"
4748

4849
[tool.poetry.dev-dependencies]
4950
parameterized = "*"

tests/test_dbt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def test_integration_basic_dbt(self):
420420
# 4 with no diffs
421421
assert diff_string.count("No row differences") == 4
422422
# 1 with a diff
423-
assert diff_string.count("| Rows Added | Rows Removed") == 1
423+
assert diff_string.count(" Rows Added Rows Removed") == 1
424424

425425
def test_integration_cloud_dbt(self):
426426
project_dir = os.environ.get("DATA_DIFF_DBT_PROJ")

0 commit comments

Comments
 (0)