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


##########
python/pyspark/sql/profiler.py:
##########
@@ -239,3 +241,72 @@ def _profile_results(self) -> "ProfileResults":
         with self._lock:
             value = self._accumulator.value
             return value if value is not None else {}
+
+
+class Profile:
+    """User-facing profile API. This instance can be accessed by
+    :attr:`spark.profile`.
+
+    .. versionadded: 4.0.0
+    """
+
+    def __init__(self, sparkSession: "SparkSession"):
+        self.sparkSession = sparkSession
+
+    def show(self, *, type: Optional[str] = None, id: Optional[int] = None) -> 
None:
+        """
+        Show the profile results.
+
+        .. versionadded:: 4.0.0
+
+        Parameters
+        ----------
+        type : str, optional
+            The profiler type, which can be either "perf" or "memory".
+        id : int, optional
+            A UDF ID to be shown. If not specified, all the results will be 
shown.
+        """
+        if type == "memory":
+            self.sparkSession.showMemoryProfiles(id)

Review Comment:
   Sounds good!



-- 
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]

Reply via email to