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


##########
python/pyspark/sql/connect/udf.py:
##########
@@ -47,6 +48,41 @@
     from pyspark.sql.types import StringType
 
 
+def _create_py_udf(
+    f: Callable[..., Any],
+    returnType: "DataTypeOrString",
+    evalType: int,
+    useArrow: Optional[bool] = None,
+) -> "UserDefinedFunctionLike":
+    from pyspark.sql.udf import _create_arrow_py_udf
+    from pyspark.sql.connect.session import _active_spark_session
+
+    if _active_spark_session is None:
+        is_arrow_enabled = False
+    else:
+        is_arrow_enabled = (
+            
_active_spark_session.conf.get("spark.sql.execution.pythonUDF.arrow.enabled") 
== "true"
+            if useArrow is None
+            else useArrow
+        )
+
+    regular_udf = _create_udf(f, returnType, evalType)

Review Comment:
   There is duplicated code in `_create_py_udf` between Spark Connect Python 
Client and vanilla PySpark, except for fetching the active SparkSession.
   However, for a clear code path separation and abstraction, I decided not to 
refactor it for now.



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