You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "allisonwang-db (via GitHub)" <gi...@apache.org> on 2023/10/27 00:52:06 UTC
Re: [PR] [SPARK-45555][PYTHON] Includes a debuggable object for failed assertion [spark]
allisonwang-db commented on code in PR #43444:
URL: https://github.com/apache/spark/pull/43444#discussion_r1373964724
##########
python/pyspark/testing/utils.py:
##########
@@ -592,20 +617,22 @@ def assert_rows_equal(rows1: List[Row], rows2: List[Row]):
rows_str2 += str(r2) + "\n"
if not compare_rows(r1, r2):
diff_rows_cnt += 1
- diff_rows = True
+ has_diff_rows = True
+ if includeDiffRows:
+ diff_rows.append((r1, r2))
generated_diff = _context_diff(
actual=rows_str1.splitlines(), expected=rows_str2.splitlines(), n=len(zipped)
)
- if diff_rows:
+ if has_diff_rows:
error_msg = "Results do not match: "
percent_diff = (diff_rows_cnt / len(zipped)) * 100
error_msg += "( %.5f %% )" % percent_diff
error_msg += "\n" + "\n".join(generated_diff)
+ data = diff_rows if includeDiffRows else None
raise PySparkAssertionError(
- error_class="DIFFERENT_ROWS",
- message_parameters={"error_msg": error_msg},
+ error_class="DIFFERENT_ROWS", message_parameters={"error_msg": error_msg}, data=data
Review Comment:
Can we add some tests for this new functionality in `test_utils`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org