xinrong-meng commented on code in PR #48143:
URL: https://github.com/apache/spark/pull/48143#discussion_r1767824896
##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -12227,6 +12265,52 @@ def unhex(col: "ColumnOrName") -> Column:
return _invoke_function_over_columns("unhex", col)
+@_try_remote_functions
+def uniform(
+ min: Union[Column, int, float],
+ max: Union[Column, int, float],
+ seed: Optional[Union[Column, int]] = None,
+) -> Column:
+ """Returns a random value with independent and identically distributed
(i.i.d.) values with the
+ specified range of numbers. The random seed is optional. The provided
numbers specifying the
+ minimum and maximum values of the range must be constant. If both of these
numbers are integers,
+ then the result will also be an integer. Otherwise if one or both of these
are floating-point
+ numbers, then the result will also be a floating-point number.
+
+ .. versionadded:: 4.0.0
+
+ Parameters
+ ----------
+ min : :class:`~pyspark.sql.Column`, int, or float
+ Minimum value in the range.
+ max : :class:`~pyspark.sql.Column`, int, or float
+ Maximum value in the range.
+ seed : :class:`~pyspark.sql.Column` or int
+ Optional random number seed to use.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ The generated random number within the specified range.
+
+ Examples
+ --------
+ >>> from pyspark.sql import functions as sf
+ >>> df = spark.createDataFrame([('3',)], ['a'])
+ >>> df.select(sf.uniform(lit(0), lit(10), lit(0)).alias('result')).show()
+ +------+
+ |result|
+ +------+
+ | 7|
+ +------+
+
Review Comment:
ditto
--
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]