dtenedor commented on code in PR #48143:
URL: https://github.com/apache/spark/pull/48143#discussion_r1774154034


##########
python/pyspark/sql/connect/functions/builtin.py:
##########
@@ -1008,6 +1008,22 @@ def unhex(col: "ColumnOrName") -> Column:
 unhex.__doc__ = pysparkfuncs.unhex.__doc__
 
 
+def uniform(
+    min: Union[Column, int, float],
+    max: Union[Column, int, float],
+    seed: Optional[Union[Column, int]] = None,
+) -> Column:
+    if seed is None:
+        return _invoke_function_over_columns(
+            "uniform", min, max, lit(random.randint(0, sys.maxsize))

Review Comment:
   Thanks, this is done.



##########
python/pyspark/sql/connect/functions/builtin.py:
##########
@@ -2578,6 +2594,16 @@ def regexp_like(str: "ColumnOrName", regexp: 
"ColumnOrName") -> Column:
 regexp_like.__doc__ = pysparkfuncs.regexp_like.__doc__
 
 
+def randstr(length: Union[Column, int], seed: Optional[Union[Column, int]] = 
None) -> Column:
+    if seed is None:
+        return _invoke_function_over_columns("randstr", length, 
lit(random.randint(0, sys.maxsize)))
+    else:
+        return _invoke_function_over_columns("randstr", length, seed)

Review Comment:
   Thanks, this is done.



##########
python/pyspark/sql/connect/functions/builtin.py:
##########
@@ -1008,6 +1008,22 @@ def unhex(col: "ColumnOrName") -> Column:
 unhex.__doc__ = pysparkfuncs.unhex.__doc__
 
 
+def uniform(
+    min: Union[Column, int, float],
+    max: Union[Column, int, float],
+    seed: Optional[Union[Column, int]] = None,
+) -> Column:
+    if seed is None:
+        return _invoke_function_over_columns(
+            "uniform", min, max, lit(random.randint(0, sys.maxsize))
+        )
+    else:
+        return _invoke_function_over_columns("uniform", min, max, seed)

Review Comment:
   Thanks, this is done.



##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -11861,6 +11861,47 @@ 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
+    --------
+    >>> spark.createDataFrame([('3',)], ['a']) \\
+    ...   .select(randstr(lit(5), lit(0)).alias('result')) \\
+    ...   .selectExpr("length(result) > 0").show()
+    +--------------------+
+    |(length(result) > 0)|
+    +--------------------+
+    |                true|
+    +--------------------+
+    """
+    length = _enum_to_value(length)
+    length = lit(length) if isinstance(length, int) else length

Review Comment:
   Thanks, updated.



##########
python/pyspark/sql/connect/functions/builtin.py:
##########
@@ -2578,6 +2594,16 @@ def regexp_like(str: "ColumnOrName", regexp: 
"ColumnOrName") -> Column:
 regexp_like.__doc__ = pysparkfuncs.regexp_like.__doc__
 
 
+def randstr(length: Union[Column, int], seed: Optional[Union[Column, int]] = 
None) -> Column:
+    if seed is None:
+        return _invoke_function_over_columns("randstr", length, 
lit(random.randint(0, sys.maxsize)))

Review Comment:
   Thanks, this is done.



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