xinrong-meng commented on code in PR #45378:
URL: https://github.com/apache/spark/pull/45378#discussion_r1515212345


##########
python/pyspark/sql/profiler.py:
##########
@@ -224,6 +224,54 @@ def dump(id: int) -> None:
             for id in sorted(code_map.keys()):
                 dump(id)
 
+    def clear_perf_profiles(self, id: Optional[int] = None) -> None:
+        """
+        Clear the perf profile results.
+
+        .. versionadded:: 4.0.0
+
+        Parameters
+        ----------
+        id : int, optional
+            The UDF ID whose profiling results should be cleared.
+            If not specified, all the results will be cleared.
+        """
+        ids_to_remove = [
+            result_id
+            for result_id, (perf, _, *_) in self._profile_results.items()
+            if perf is not None
+        ]
+        with self._lock:
+            if id is not None:
+                if id in ids_to_remove:
+                    self._profile_results.pop(id, None)

Review Comment:
   Good catch! Thanks for the example. I adjusted the code and added tests.



-- 
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-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to