physinet opened a new pull request, #37329: URL: https://github.com/apache/spark/pull/37329
### What changes were proposed in this pull request? Support either literal Python strings or Column objects for the pattern and replacement arguments for `regexp_replace`. ### Why are the changes needed? Allows using different replacements per row, as in [this example](https://stackoverflow.com/questions/64613761/in-pyspark-using-regexp-replace-how-to-replace-a-group-with-value-from-another,). ### Does this PR introduce _any_ user-facing change? Users can now use `regexp_replace` with columns for all three arguments. The first argument (string that regex should be applied to) can be either a Column object or the string name of the column. In summary, the following signatures are supported: ```python regexp_replace("str", "\d", "") regexp_replace(F.col("str"), "\d", "") regexp_replace("str", F.col("pattern"), F.col("replacement")) regexp_replace(F.col("str"), F.col("pattern"), F.col("replacement")) ``` ### How was this patch tested? Added unit tests -- 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]
