This is an automated email from the ASF dual-hosted git repository.

gurwls223 pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.5 by this push:
     new 39b3dd72bec Revert "[SPARK-43660][CONNECT][PS][FOLLOWUP] Remove JVM 
dependency for resample"
39b3dd72bec is described below

commit 39b3dd72bec3f78b55348007dbeaab67d15165f6
Author: Hyukjin Kwon <gurwls...@apache.org>
AuthorDate: Wed Aug 9 20:34:19 2023 +0900

    Revert "[SPARK-43660][CONNECT][PS][FOLLOWUP] Remove JVM dependency for 
resample"
    
    This reverts commit 2e566a5b6d3871315b9115753ebb1aab75cdbe13.
---
 python/pyspark/pandas/resample.py | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/python/pyspark/pandas/resample.py 
b/python/pyspark/pandas/resample.py
index 0d2c3cc753c..30f8c9d3169 100644
--- a/python/pyspark/pandas/resample.py
+++ b/python/pyspark/pandas/resample.py
@@ -67,6 +67,7 @@ from pyspark.pandas.utils import (
     scol_for,
     verify_temp_column_name,
 )
+from pyspark.sql.utils import is_remote
 from pyspark.pandas.spark.functions import timestampdiff
 
 
@@ -144,15 +145,22 @@ class Resampler(Generic[FrameLike], metaclass=ABCMeta):
     def get_make_interval(  # type: ignore[return]
         self, unit: str, col: Union[Column, int, float]
     ) -> Column:
-        col = col if not isinstance(col, (int, float)) else F.lit(col)  # 
type: ignore[assignment]
-        if unit == "MONTH":
-            return F.make_interval(months=col)  # type: ignore
-        if unit == "HOUR":
-            return F.make_interval(hours=col)  # type: ignore
-        if unit == "MINUTE":
-            return F.make_interval(mins=col)  # type: ignore
-        if unit == "SECOND":
-            return F.make_interval(secs=col)  # type: ignore
+        if is_remote():
+            from pyspark.sql.connect.functions import lit, make_interval
+
+            col = col if not isinstance(col, (int, float)) else lit(col)  # 
type: ignore[assignment]
+            if unit == "MONTH":
+                return make_interval(months=col)  # type: ignore
+            if unit == "HOUR":
+                return make_interval(hours=col)  # type: ignore
+            if unit == "MINUTE":
+                return make_interval(mins=col)  # type: ignore
+            if unit == "SECOND":
+                return make_interval(secs=col)  # type: ignore
+        else:
+            sql_utils = SparkContext._active_spark_context._jvm.PythonSQLUtils
+            col = col._jc if isinstance(col, Column) else F.lit(col)._jc
+            return sql_utils.makeInterval(unit, col)
 
     def _bin_timestamp(self, origin: pd.Timestamp, ts_scol: Column) -> Column:
         key_type = self._resamplekey_type


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to