physinet commented on code in PR #37329:
URL: https://github.com/apache/spark/pull/37329#discussion_r933229230
##########
python/pyspark/sql/functions.py:
##########
@@ -3262,7 +3262,19 @@ def regexp_extract(str: "ColumnOrName", pattern: str,
idx: int) -> Column:
return _invoke_function("regexp_extract", _to_java_column(str), pattern,
idx)
-def regexp_replace(str: "ColumnOrName", pattern: str, replacement: str) ->
Column:
+@overload
+def regexp_replace(string: "ColumnOrName", pattern: str, replacement: str) ->
Column:
+ ...
+
+
+@overload
+def regexp_replace(string: "ColumnOrName", pattern: Column, replacement:
Column) -> Column:
+ ...
+
+
+def regexp_replace(
+ string: "ColumnOrName", pattern: Union[str, Column], replacement:
Union[str, Column]
Review Comment:
Added Parameters to the docstring:
[45cd79d](https://github.com/apache/spark/pull/37329/commits/45cd79ddd205ff317f0061fdcf19972f84bbee91)
The types make it somewhat unclear that pattern and replacement must be
either _both_ strings or _both_ columns to match the signatures
[here](https://github.com/apache/spark/blob/775b5ced70c87d6a8709f44eb4a5de48c286a51d/sql/core/src/main/scala/org/apache/spark/sql/functions.scala#L2826).
This is why I had the overloaded signatures. I removed them and tried to
clarify in the docstring instead.
--
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]