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

include only rows with equal PK to values diff stats in --json output #631

Merged
merged 1 commit into from
Jun 28, 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
6 changes: 4 additions & 2 deletions data_diff/diff_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ def get_stats_string(self, is_dbt: bool = False):

return string_output

def get_stats_dict(self):
diff_stats = self._get_stats()
def get_stats_dict(self, is_dbt: bool = False):
diff_stats = self._get_stats(is_dbt)
json_output = {
"rows_A": diff_stats.table1_count,
"rows_B": diff_stats.table2_count,
Expand All @@ -177,6 +177,8 @@ def get_stats_dict(self):
"total": sum(diff_stats.diff_by_sign.values()),
"stats": self.stats,
}
if diff_stats.extra_column_diffs:
json_output["values"] = diff_stats.extra_column_diffs

return json_output

Expand Down
4 changes: 2 additions & 2 deletions data_diff/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def jsonify(

summary = None
if with_summary:
summary = _jsonify_diff_summary(diff.get_stats_dict())
summary = _jsonify_diff_summary(diff.get_stats_dict(is_dbt=True))

columns = None
if with_columns:
Expand Down Expand Up @@ -258,7 +258,7 @@ def _jsonify_diff_summary(stats_dict: dict) -> JsonDiffSummary:
updated=stats_dict["updated"],
unchanged=stats_dict["unchanged"],
),
stats=Stats(diffCounts=stats_dict["stats"]["diff_counts"]),
stats=Stats(diffCounts=stats_dict["values"]),
)


Expand Down