You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ru...@apache.org on 2023/06/10 07:25:24 UTC
[spark] branch master updated: [SPARK-43621][PS][CONNECT] Enable `pyspark.pandas.spark.functions.repeat` in Spark Connect
This is an automated email from the ASF dual-hosted git repository.
ruifengz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new f74646e23da [SPARK-43621][PS][CONNECT] Enable `pyspark.pandas.spark.functions.repeat` in Spark Connect
f74646e23da is described below
commit f74646e23da715d4be06f1436558ca09761dff91
Author: Ruifeng Zheng <ru...@apache.org>
AuthorDate: Sat Jun 10 15:25:06 2023 +0800
[SPARK-43621][PS][CONNECT] Enable `pyspark.pandas.spark.functions.repeat` in Spark Connect
### What changes were proposed in this pull request?
Enable `pyspark.pandas.spark.functions.repeat` in Spark Connect
### Why are the changes needed?
feature parity
### Does this PR introduce _any_ user-facing change?
yes, new method enabled
### How was this patch tested?
enabled UTs
Closes #41524 from zhengruifeng/ps_con_repeat.
Authored-by: Ruifeng Zheng <ru...@apache.org>
Signed-off-by: Ruifeng Zheng <ru...@apache.org>
---
python/pyspark/pandas/spark/functions.py | 6 +++---
.../tests/connect/computation/test_parity_binary_ops.py | 6 ------
.../tests/connect/data_type_ops/test_parity_num_ops.py | 6 ------
.../tests/connect/data_type_ops/test_parity_string_ops.py | 12 ------------
.../pandas/tests/connect/test_parity_series_string.py | 6 +-----
5 files changed, 4 insertions(+), 32 deletions(-)
diff --git a/python/pyspark/pandas/spark/functions.py b/python/pyspark/pandas/spark/functions.py
index f4c0261134e..7f360a9715f 100644
--- a/python/pyspark/pandas/spark/functions.py
+++ b/python/pyspark/pandas/spark/functions.py
@@ -20,6 +20,7 @@ Additional Spark functions used in pandas-on-Spark.
from typing import Union, no_type_check
from pyspark import SparkContext
+import pyspark.sql.functions as F
from pyspark.sql.column import (
Column,
_to_java_column,
@@ -90,9 +91,8 @@ 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)
+ _n = F.lit(n) if isinstance(n, int) else n
+ return F.call_udf("repeat", col, _n)
def date_part(field: Union[str, Column], source: Column) -> Column:
diff --git a/python/pyspark/pandas/tests/connect/computation/test_parity_binary_ops.py b/python/pyspark/pandas/tests/connect/computation/test_parity_binary_ops.py
index 58d5b55d8b9..2b10c331181 100644
--- a/python/pyspark/pandas/tests/connect/computation/test_parity_binary_ops.py
+++ b/python/pyspark/pandas/tests/connect/computation/test_parity_binary_ops.py
@@ -27,12 +27,6 @@ class FrameParityBinaryOpsTests(FrameBinaryOpsMixin, PandasOnSparkTestUtils, Reu
def psdf(self):
return ps.from_pandas(self.pdf)
- @unittest.skip(
- "TODO(SPARK-43616): Enable pyspark.pandas.spark.functions.repeat in Spark Connect."
- )
- def test_binary_operator_multiply(self):
- super().test_binary_operator_multiply()
-
if __name__ == "__main__":
from pyspark.pandas.tests.connect.computation.test_parity_binary_ops import * # noqa: F401
diff --git a/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_num_ops.py b/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_num_ops.py
index 09e2c9b1112..b65873c6ab5 100644
--- a/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_num_ops.py
+++ b/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_num_ops.py
@@ -38,12 +38,6 @@ class NumOpsParityTests(
def test_eq(self):
super().test_eq()
- @unittest.skip(
- "TODO(SPARK-43621): Enable pyspark.pandas.spark.functions.repeat in Spark Connect."
- )
- def test_mul(self):
- super().test_mul()
-
@unittest.skip("TODO(SPARK-43691): Enable NumOpsParityTests.test_ne.")
def test_ne(self):
super().test_ne()
diff --git a/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_string_ops.py b/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_string_ops.py
index 2d81db1c701..ecbf94a6bde 100644
--- a/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_string_ops.py
+++ b/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_string_ops.py
@@ -34,18 +34,6 @@ class StringOpsParityTests(
def test_astype(self):
super().test_astype()
- @unittest.skip(
- "TODO(SPARK-43621): Enable pyspark.pandas.spark.functions.repeat in Spark Connect."
- )
- def test_mul(self):
- super().test_mul()
-
- @unittest.skip(
- "TODO(SPARK-43621): Enable pyspark.pandas.spark.functions.repeat in Spark Connect."
- )
- def test_rmul(self):
- super().test_rmul()
-
if __name__ == "__main__":
from pyspark.pandas.tests.connect.data_type_ops.test_parity_string_ops import * # noqa: F401
diff --git a/python/pyspark/pandas/tests/connect/test_parity_series_string.py b/python/pyspark/pandas/tests/connect/test_parity_series_string.py
index c8e529d9df0..d7c0335f15c 100644
--- a/python/pyspark/pandas/tests/connect/test_parity_series_string.py
+++ b/python/pyspark/pandas/tests/connect/test_parity_series_string.py
@@ -24,11 +24,7 @@ from pyspark.testing.pandasutils import PandasOnSparkTestUtils
class SeriesStringParityTests(
SeriesStringTestsMixin, PandasOnSparkTestUtils, ReusedConnectTestCase
):
- @unittest.skip(
- "TODO(SPARK-43621): Enable pyspark.pandas.spark.functions.repeat in Spark Connect."
- )
- def test_string_repeat(self):
- super().test_string_repeat()
+ pass
if __name__ == "__main__":
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org