zhengruifeng commented on code in PR #52689:
URL: https://github.com/apache/spark/pull/52689#discussion_r2450242603


##########
python/pyspark/sql/tests/test_udf.py:
##########
@@ -1551,6 +1554,98 @@ def check_struct_binary_type(s):
                 expected = 
self.spark.createDataFrame([Row(type_name=expected_type)])
                 assertDataFrameEqual(result, expected)
 
+    @unittest.skipIf(is_remote_only(), "Requires JVM access")
+    def test_udf_with_logging(self):
+        @udf
+        def my_udf():
+            logger = logging.getLogger("test")
+            print("print to stdout ❤", file=sys.stdout)
+            print("print to stderr 😀", file=sys.stderr)
+            try:
+                1 / 0
+            except Exception:
+                logger.exception("exception")
+            return "x"
+
+        # Logging is disabled by default
+        assertDataFrameEqual(
+            self.spark.range(1).select(my_udf().alias("result")), 
[Row(result="x")]
+        )
+        
self.assertEqual(self.spark.table("system.session.python_worker_logs").count(), 
0)
+
+        with self.sql_conf({"spark.sql.pyspark.worker.logging.enabled": 
"true"}):
+            assertDataFrameEqual(
+                self.spark.range(1).select(my_udf().alias("result")), 
[Row(result="x")]
+            )
+
+        logs = self.spark.table("system.session.python_worker_logs")

Review Comment:
   will this view name `system.session.python_worker_logs` be configurable?



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