All functions in this section accept zero or one arguments. The only use of the argument (if provided) is to prevent common subexpression elimination such that two different executions within a row of the same random function return different random values. Related contentDocumentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
The random numbers are generated by non-cryptographic algorithms.
The documentation below is generated from the
system.functions system table.fuzzBits
Introduced in: v20.5.0 Flips the bits of the input strings, with probability p for each bit.
Syntax
s— String or FixedString to perform bit fuzzing onStringorFixedStringp— Probability of flipping each bit as a number between0.0and1.0Float*
s. String or FixedString
Examples
Usage example
Query
Response
rand
Introduced in: v1.1.0 Returns a randomUInt32 number with uniform distribution.
Uses a linear congruential generator with an initial state obtained from the system, which means that while it appears random, it’s not truly random and can be predictable if the initial state is known.
For scenarios where true randomness is crucial, consider using alternative methods like system-level calls or integrating with external libraries.
Syntax
rand32
Arguments
x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
UInt32. UInt32
Examples
Usage example
Query
Response
rand64
Introduced in: v1.1.0 Returns a random distributedUInt64 number with uniform distribution.
Uses a linear congruential generator with an initial state obtained from the system, which means that while it appears random, it’s not truly random and can be predictable if the initial state is known.
For scenarios where true randomness is crucial, consider using alternative methods like system-level calls or integrating with external libraries.
Syntax
x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
UInt64
Examples
Usage example
Query
Response
randBernoulli
Introduced in: v22.10.0 Returns a random Float64 number drawn from a Bernoulli distribution. Syntaxprobability— The probability of success as a value between0and1.Float64x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
UInt64
Examples
Usage example
Query
Response
randBinomial
Introduced in: v22.10.0 Returns a random Float64 number drawn from a binomial distribution. Syntaxexperiments— The number of experimentsUInt64probability— The probability of success in each experiment as a value between0and1Float64x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
UInt64
Examples
Usage example
Query
Response
randCanonical
Introduced in: v22.11.0 Returns a random distributedFloat64 number with uniform distribution between 0 (inclusive) and 1 (exclusive).
Syntax
x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
Float64
Examples
Usage example
Query
Response
randChiSquared
Introduced in: v22.10.0 Returns a random Float64 number drawn from a chi-square distribution. Syntaxdegree_of_freedom— Degrees of freedom.Float64x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
Float64
Examples
Usage example
Query
Response
randConstant
Introduced in: v1.1.0 Generates a single random value that remains constant across all rows in the current query execution. This function:- Returns the same random value for every row within a single query
- Produces different values across separate query executions
x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
UInt32 containing the same random value in each row. UInt32
Examples
Basic usage
Query
Response
Query
Response
randExponential
Introduced in: v22.10.0 Returns a random Float64 number drawn from an exponential distribution. Syntaxlambda— Rate parameter or lambda value of the distributionFloat64x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
Float64
Examples
Usage example
Query
Response
randFisherF
Introduced in: v22.10.0 Returns a random Float64 number drawn from an F-distribution. Syntaxd1— d1 degree of freedom inX = (S1 / d1) / (S2 / d2).Float64d2— d2 degree of freedom inX = (S1 / d1) / (S2 / d2).Float64x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
Float64
Examples
Usage example
Query
Response
randLogNormal
Introduced in: v22.10.0 Returns a random Float64 number drawn from a log-normal distribution. Syntaxmean— The mean value of distribution.Float64stddev— The standard deviation of the distribution.Float64x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
Float64
Examples
Usage example
Query
Response
randNegativeBinomial
Introduced in: v22.10.0 Returns a random Float64 number drawn from a negative binomial distribution. Syntaxexperiments— The number of experiments.UInt64probability—The probability of failure in each experiment as a value between0and1. [Float64`](/reference/data-types/float)x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
UInt64
Examples
Usage example
Query
Response
randNormal
Introduced in: v22.10.0 Returns a random Float64 number drawn from a normal distribution. Syntaxmean— The mean value of distributionFloat64stddev— The standard deviation of the distributionFloat64x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
Float64
Examples
Usage example
Query
Response
randPoisson
Introduced in: v22.10.0 Returns a random Float64 number drawn from a Poisson distribution distribution. Syntaxn— The mean number of occurrences.UInt64x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
UInt64
Examples
Usage example
Query
Response
randStudentT
Introduced in: v22.10.0 Returns a random Float64 number drawn from a Student’s t-distribution. Syntaxdegree_of_freedom— Degrees of freedom.Float64x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
Float64
Examples
Usage example
Query
Response
randUniform
Introduced in: v22.10.0 Returns a random Float64 number drawn uniformly from the interval . Syntaxmin— Left boundary of the range (inclusive).Float64max— Right boundary of the range (inclusive).Float64x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
min and max. Float64
Examples
Usage example
Query
Response
randomFixedString
Introduced in: v20.5.0 Generates a random fixed-size string with the specified number of character. The returned characters are not necessarily ASCII characters, i.e. they may not be printable. Syntaxlength— Length of the string in bytes.UInt*
FixedString
Examples
Usage example
Query
Response
randomPrintableASCII
Introduced in: v20.1.0 Generates a random ASCII string with the specified number of characters. If you passlength < 0, the behavior of the function is undefined.
Syntax
length— String length in bytes.(U)Int*x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
String
Examples
Usage example
Query
Response
randomString
Introduced in: v20.5.0 Generates a random string with the specified number of characters. The returned characters are not necessarily ASCII characters, i.e. they may not be printable. Syntaxlength— Length of the string in bytes.(U)Int*x— Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query.Any
String
Examples
Usage example
Query
Response
randomStringUTF8
Introduced in: v20.5.0 Generates a random UTF-8 string with the specified number of codepoints. No codepoints from unassigned planes (planes 4 to 13) are returned. It is still possible that the client interacting with ClickHouse server is not able to display the produced UTF-8 string correctly. Syntaxlength— Length of the string in code points.(U)Int*
String
Examples
Usage example
Query
Response