HyukjinKwon commented on code in PR #40722:
URL: https://github.com/apache/spark/pull/40722#discussion_r1161532792
##########
python/pyspark/pandas/data_type_ops/num_ops.py:
##########
@@ -300,9 +396,16 @@ def rfloordiv(self, left: IndexOpsLike, right: Any) ->
SeriesOrIndex:
if not isinstance(right, numbers.Number):
raise TypeError("Floor division can not be applied to given
types.")
- def rfloordiv(left: GenericColumn, right: Any) -> GenericColumn:
+ if is_remote():
+ from pyspark.sql.connect.column import Column as ConnectColumn
+
+ Column = ConnectColumn
+ else:
+ Column = PySparkColumn # type: ignore[assignment]
+
+ def rfloordiv(left: Column, right: Any) -> Column: # type:
ignore[valid-type]
Review Comment:
ditto remove
##########
python/pyspark/pandas/data_type_ops/num_ops.py:
##########
@@ -334,18 +437,33 @@ def mul(self, left: IndexOpsLike, right: Any) ->
SeriesOrIndex:
raise TypeError("Multiplication can not be applied to given
types.")
right = transform_boolean_operand_to_numeric(right,
spark_type=left.spark.data_type)
- Column: Type[GenericColumn] = ConnectColumn if is_remote() else
PySparkColumn
- return column_op(cast(Callable[..., GenericColumn],
Column.__mul__))(left, right)
+ if is_remote():
+ from pyspark.sql.connect.column import Column as ConnectColumn
+
+ Column = ConnectColumn
+ else:
+ Column = PySparkColumn # type: ignore[assignment]
+ return column_op(Column.__mul__)(left, right) # type: ignore[arg-type]
def truediv(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex:
_sanitize_list_like(right)
if not is_valid_operand_for_numeric_arithmetic(right):
raise TypeError("True division can not be applied to given types.")
- def truediv(left: GenericColumn, right: Any) -> GenericColumn:
- return F.when(F.lit(right != 0) | F.lit(right).isNull(),
left.__div__(right)).otherwise(
+ if is_remote():
+ from pyspark.sql.connect.column import Column as ConnectColumn
+
+ Column = ConnectColumn
+ else:
+ Column = PySparkColumn # type: ignore[assignment]
+
+ def truediv(left: Column, right: Any) -> Column: # type:
ignore[valid-type]
Review Comment:
ditto remove
##########
python/pyspark/pandas/data_type_ops/num_ops.py:
##########
@@ -357,14 +475,21 @@ def floordiv(self, left: IndexOpsLike, right: Any) ->
SeriesOrIndex:
if not is_valid_operand_for_numeric_arithmetic(right):
raise TypeError("Floor division can not be applied to given
types.")
- def floordiv(left: GenericColumn, right: Any) -> GenericColumn:
+ if is_remote():
+ from pyspark.sql.connect.column import Column as ConnectColumn
+
+ Column = ConnectColumn
+ else:
+ Column = PySparkColumn # type: ignore[assignment]
+
+ def floordiv(left: Column, right: Any) -> Column: # type:
ignore[valid-type]
Review Comment:
ditto remove
--
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]