xinrong-meng commented on code in PR #48143:
URL: https://github.com/apache/spark/pull/48143#discussion_r1767824661


##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -11861,6 +11861,44 @@ def regexp_like(str: "ColumnOrName", regexp: 
"ColumnOrName") -> Column:
     return _invoke_function_over_columns("regexp_like", str, regexp)
 
 
+@_try_remote_functions
+def randstr(length: Union[Column, int], seed: Optional[Union[Column, int]] = 
None) -> Column:
+    """Returns a string of the specified length whose characters are chosen 
uniformly at random from
+    the following pool of characters: 0-9, a-z, A-Z. The random seed is 
optional. The string length
+    must be a constant two-byte or four-byte integer (SMALLINT or INT, 
respectively).
+
+    .. versionadded:: 4.0.0
+
+    Parameters
+    ----------
+    length : :class:`~pyspark.sql.Column` or int
+        Number of characters in the string to generate.
+    seed : :class:`~pyspark.sql.Column` or int
+        Optional random number seed to use.
+
+    Returns
+    -------
+    :class:`~pyspark.sql.Column`
+        The generated random string with the specified length.
+
+    Examples
+    --------
+    >>> from pyspark.sql import functions as sf
+    >>> df = spark.createDataFrame([('3',)], ['a'])
+    >>> df.select(sf.randstr(lit(5), lit(0)).alias('result')).show()
+    +------+
+    |result|
+    +------+
+    | ceV0P|
+    +------+
+

Review Comment:
   nit: we normally don't include an empty line at the end of the docstring



-- 
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]

Reply via email to