ueshin commented on code in PR #44697:
URL: https://github.com/apache/spark/pull/44697#discussion_r1456469906
##########
python/pyspark/sql/tests/test_udf_profiler.py:
##########
@@ -145,6 +155,190 @@ def test_unsupported(self):
)
+class UDFProfiler2TestsMixin:
+ @contextmanager
+ def trap_stdout(self):
+ old_stdout = sys.stdout
+ sys.stdout = io = StringIO()
+ try:
+ yield io
+ finally:
+ sys.stdout = old_stdout
+
+ @property
+ def profile_results(self):
+ return self.spark._profiler_collector._perf_profile_results
+
+ def test_perf_profiler_udf(self):
+ _do_computation(self.spark)
+
+ # Without the conf enabled, no profile results are collected.
+ self.assertEqual(0, len(self.profile_results),
str(list(self.profile_results)))
+
+ with self.sql_conf({"spark.sql.pyspark.udf.profiler": "perf"}):
+ _do_computation(self.spark)
+
+ self.assertEqual(3, len(self.profile_results),
str(list(self.profile_results)))
+
+ with self.trap_stdout() as io_all:
+ self.spark.show_perf_profiles()
Review Comment:
Sure, let me change it to `showPerfProfiles`.
##########
python/pyspark/sql/profiler.py:
##########
@@ -0,0 +1,176 @@
+#
Review Comment:
No, the new config and `spark.showPerfProfiles` should be the new user
facing API.
--
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]