@@ -60,25 +60,7 @@ def jsonify(
6060 t1_exclusive_rows , t2_exclusive_rows , diff_rows = _group_rows (diff_info , schema )
6161
6262 if not stats_only :
63- diff_rows_jsonified = []
64- for row in diff_rows :
65- diff_rows_jsonified .append (_jsonify_diff (row , key_columns ))
66-
67- t1_exclusive_rows_jsonified = []
68- for row in t1_exclusive_rows :
69- t1_exclusive_rows_jsonified .append (_jsonify_exclusive (row , key_columns ))
70-
71- t2_exclusive_rows_jsonified = []
72- for row in t2_exclusive_rows :
73- t2_exclusive_rows_jsonified .append (_jsonify_exclusive (row , key_columns ))
74-
75- rows = RowsDiff (
76- exclusive = ExclusiveDiff (
77- dataset1 = t1_exclusive_rows_jsonified ,
78- dataset2 = t2_exclusive_rows_jsonified
79- ),
80- diff = diff_rows_jsonified ,
81- )
63+ rows = _make_rows_diff (t1_exclusive_rows , t2_exclusive_rows , diff_rows )
8264
8365 summary = None
8466 if with_summary :
@@ -267,6 +249,32 @@ def _group_rows(
267249 return t1_exclusive_rows , t2_exclusive_rows , diff_rows
268250
269251
252+ def _make_rows_diff (
253+ t1_exclusive_rows : List [Dict [str , Any ]],
254+ t2_exclusive_rows : List [Dict [str , Any ]],
255+ diff_rows : List [Dict [str , Any ]]
256+ ) -> RowsDiff :
257+ diff_rows_jsonified = []
258+ for row in diff_rows :
259+ diff_rows_jsonified .append (_jsonify_diff (row , key_columns ))
260+
261+ t1_exclusive_rows_jsonified = []
262+ for row in t1_exclusive_rows :
263+ t1_exclusive_rows_jsonified .append (_jsonify_exclusive (row , key_columns ))
264+
265+ t2_exclusive_rows_jsonified = []
266+ for row in t2_exclusive_rows :
267+ t2_exclusive_rows_jsonified .append (_jsonify_exclusive (row , key_columns ))
268+
269+ return RowsDiff (
270+ exclusive = ExclusiveDiff (
271+ dataset1 = t1_exclusive_rows_jsonified ,
272+ dataset2 = t2_exclusive_rows_jsonified
273+ ),
274+ diff = diff_rows_jsonified ,
275+ )
276+
277+
270278def _jsonify_diff (row : Dict [str , Any ], key_columns : List [str ]) -> Dict [str , JsonDiffRowValue ]:
271279 columns = collections .defaultdict (dict )
272280 for field , value in row .items ():
0 commit comments