ueshin commented on code in PR #41606:
URL: https://github.com/apache/spark/pull/41606#discussion_r1253534367
##########
python/pyspark/testing/utils.py:
##########
@@ -209,3 +233,71 @@ def check_error(
self.assertEqual(
expected, actual, f"Expected message parameters was '{expected}',
got '{actual}'"
)
+
+
+def assertDataFrameEqual(
+ df: DataFrame, expected: Union[DataFrame, List[Row]], ignore_row_order:
bool = True
+):
+ if df is None and expected is None:
+ return True
+ elif df is None or expected is None:
+ return False
+
+ def compare(r1: Row, r2: Row):
+ if r1 is None and r2 is None:
+ return True
+ elif r1 is None or r2 is None:
+ return False
+
+ d1 = r1.asDict()
+ d2 = r2.asDict()
+
+ for key in d1.keys() & d2.keys():
+ if isinstance(d1[key], float) and isinstance(d2[key], float):
+ if abs(d1[key] - d2[key]) > 1e-5:
+ return False
Review Comment:
Could you add more tests with complex types containing `float` if we want to
allow small differences like this?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]