HyukjinKwon commented on code in PR #41524:
URL: https://github.com/apache/spark/pull/41524#discussion_r1224995147


##########
python/pyspark/pandas/spark/functions.py:
##########
@@ -80,9 +80,22 @@ def repeat(col: Column, n: Union[int, Column]) -> Column:
     """
     Repeats a string column n times, and returns it as a new string column.
     """
-    sc = SparkContext._active_spark_context
-    n = _to_java_column(n) if isinstance(n, Column) else 
_create_column_from_literal(n)
-    return _call_udf(sc, "repeat", _to_java_column(col), n)
+    if is_remote():
+        from pyspark.sql.connect.functions import lit, call_udf
+
+        if isinstance(n, int):
+            n = lit(n)  # type: ignore[assignment]
+
+        return call_udf(  # type: ignore[return-value]
+            "repeat",
+            col,  # type: ignore[arg-type]
+            n,  # type: ignore[arg-type]
+        )
+
+    else:
+        sc = SparkContext._active_spark_context
+        n = _to_java_column(n) if isinstance(n, Column) else 
_create_column_from_literal(n)
+        return _call_udf(sc, "repeat", _to_java_column(col), n)

Review Comment:
   actually I think we can just call `call_udf` instead without if-else.



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