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

gurwls223 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 e5e0f389dad Revert "[SPARK-43660][CONNECT][PS][FOLLOWUP] Remove JVM 
dependency for resample"
e5e0f389dad is described below

commit e5e0f389dad678e664d5e9897d40a8765a0dc2e5
Author: Hyukjin Kwon <gurwls...@apache.org>
AuthorDate: Wed Aug 9 20:33:50 2023 +0900

    Revert "[SPARK-43660][CONNECT][PS][FOLLOWUP] Remove JVM dependency for 
resample"
    
    This reverts commit b19a83e236b2732c2af6d0a4d79ebcbca4105c59.
---
 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