itholic commented on code in PR #41305:
URL: https://github.com/apache/spark/pull/41305#discussion_r1205195934
##########
python/pyspark/sql/utils.py:
##########
@@ -234,3 +236,19 @@ def wrapped(*args: Any, **kwargs: Any) -> Any:
return f(*args, **kwargs)
return cast(FuncT, wrapped)
+
+
+def pyspark_column_op(func_name: str) -> Callable[..., "SeriesOrIndex"]:
+ """
+ Wrapper function for column_op to get proper Column class.
+ """
+ from pyspark.pandas.base import column_op
+ from pyspark.sql.column import Column as PySparkColumn
+
+ if is_remote():
+ from pyspark.sql.connect.column import Column as ConnectColumn
+
+ Column = ConnectColumn
+ else:
+ Column = PySparkColumn # type: ignore[assignment]
+ return column_op(getattr(Column, func_name))
Review Comment:
> Can we get a one utility to get the column class at least? e.g.,
utils.pyspark_column_op("__lt__")
@HyukjinKwon just added util function here. If it looks good, will apply
this change to other PRs as well.
##########
python/pyspark/sql/utils.py:
##########
@@ -234,3 +236,19 @@ def wrapped(*args: Any, **kwargs: Any) -> Any:
return f(*args, **kwargs)
return cast(FuncT, wrapped)
+
+
+def pyspark_column_op(func_name: str) -> Callable[..., "SeriesOrIndex"]:
+ """
+ Wrapper function for column_op to get proper Column class.
+ """
+ from pyspark.pandas.base import column_op
+ from pyspark.sql.column import Column as PySparkColumn
+
+ if is_remote():
+ from pyspark.sql.connect.column import Column as ConnectColumn
+
+ Column = ConnectColumn
+ else:
+ Column = PySparkColumn # type: ignore[assignment]
+ return column_op(getattr(Column, func_name))
Review Comment:
> Can we get a one utility to get the column class at least? e.g.,
utils.pyspark_column_op("__lt__")
@HyukjinKwon just added util function here. If it looks good, will apply
this change to other PRs as well.
--
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]