@@ -20,6 +20,7 @@ def jsonify(
2020 dbt_model : str ,
2121 with_summary : bool = False ,
2222 with_columns : Optional [Dict [str , List [str ]]] = None ,
23+ stats_only : bool = False ,
2324) -> "JsonDiff" :
2425 """
2526 Converts the diff result into a JSON-serializable format.
@@ -33,21 +34,31 @@ def jsonify(
3334 t1_exclusive_rows = []
3435 t2_exclusive_rows = []
3536 diff_rows = []
37+ rows = None
3638 schema = [field for field , _ in diff_info .diff_schema ]
3739
3840 t1_exclusive_rows , t2_exclusive_rows , diff_rows = _group_rows (diff_info , schema )
3941
40- diff_rows_jsonified = []
41- for row in diff_rows :
42- diff_rows_jsonified .append (_jsonify_diff (row , key_columns ))
42+ if not stats_only :
43+ diff_rows_jsonified = []
44+ for row in diff_rows :
45+ diff_rows_jsonified .append (_jsonify_diff (row , key_columns ))
4346
44- t1_exclusive_rows_jsonified = []
45- for row in t1_exclusive_rows :
46- t1_exclusive_rows_jsonified .append (_jsonify_exclusive (row , key_columns ))
47+ t1_exclusive_rows_jsonified = []
48+ for row in t1_exclusive_rows :
49+ t1_exclusive_rows_jsonified .append (_jsonify_exclusive (row , key_columns ))
4750
48- t2_exclusive_rows_jsonified = []
49- for row in t2_exclusive_rows :
50- t2_exclusive_rows_jsonified .append (_jsonify_exclusive (row , key_columns ))
51+ t2_exclusive_rows_jsonified = []
52+ for row in t2_exclusive_rows :
53+ t2_exclusive_rows_jsonified .append (_jsonify_exclusive (row , key_columns ))
54+
55+ rows = RowsDiff (
56+ exclusive = ExclusiveDiff (
57+ dataset1 = t1_exclusive_rows_jsonified ,
58+ dataset2 = t2_exclusive_rows_jsonified
59+ ),
60+ diff = diff_rows_jsonified ,
61+ )
5162
5263 summary = None
5364 if with_summary :
@@ -70,10 +81,7 @@ def jsonify(
7081 model = dbt_model ,
7182 dataset1 = list (table1 .table_path ),
7283 dataset2 = list (table2 .table_path ),
73- rows = RowsDiff (
74- exclusive = ExclusiveDiff (dataset1 = t1_exclusive_rows_jsonified , dataset2 = t2_exclusive_rows_jsonified ),
75- diff = diff_rows_jsonified ,
76- ),
84+ rows = rows ,
7785 summary = summary ,
7886 columns = columns ,
7987 ).json ()
@@ -175,7 +183,7 @@ class JsonDiff:
175183 model : str
176184 dataset1 : List [str ]
177185 dataset2 : List [str ]
178- rows : RowsDiff
186+ rows : Optional [ RowsDiff ]
179187 summary : Optional [JsonDiffSummary ]
180188 columns : Optional [JsonColumnsSummary ]
181189
0 commit comments