From 27099cedcb974d704e240cedf4da547d50debb19 Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Mon, 11 Mar 2024 08:34:01 +0000 Subject: [PATCH] Some fixups --- .../functions/random-functions.md | 84 +++++-------------- .../functions/type-conversion-functions.md | 16 ++-- .../sql-reference/functions/url-functions.md | 6 +- 3 files changed, 34 insertions(+), 72 deletions(-) diff --git a/docs/en/sql-reference/functions/random-functions.md b/docs/en/sql-reference/functions/random-functions.md index b745d2833d3..2d7752ed022 100644 --- a/docs/en/sql-reference/functions/random-functions.md +++ b/docs/en/sql-reference/functions/random-functions.md @@ -20,7 +20,9 @@ The random numbers are generated by non-cryptographic algorithms. ## rand -Returns a random UInt32 number. +Returns a random UInt32 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 @@ -28,18 +30,16 @@ Returns a random UInt32 number. rand() ``` -### Parameters +Alias: `rand32` + +### Arguments None. -### Output +### Returned value Returns a number of type UInt32. -### Implementation details - -Uses a linear congruential generator. - ### Example ```sql @@ -47,44 +47,12 @@ SELECT rand(); ``` ```response -1569354847 +1569354847 -- Note: The actual output will be a random number, not the specific number shown in the example ``` -**Note:** The actual output will be a random number, not the specific number shown in the example. - -## rand32 - -Returns a random 32-bit unsigned integer (UInt32) number. - -### Syntax - -```sql -rand32() -``` - -### Parameters - -None. - -### Output - -Returns a number of type UInt32, evenly distributed across the range of all possible UInt32 values. - -### Example - -```sql -SELECT rand32(); -``` - -```response -2754546224 -``` - -**Note:** The actual output will be a random number, not the specific number shown in the example. - ## rand64 -Returns a random 64-bit unsigned integer (UInt64) number. +Returns a random UInt64 integer (UInt64) number ### Syntax @@ -92,17 +60,15 @@ Returns a random 64-bit unsigned integer (UInt64) number. rand64() ``` -### Parameters +### Arguments None. -### Output +### Returned value -Returns a number of type UInt64, evenly distributed across the range of all possible UInt64 values. +Returns a number UInt64 number with uniform distribution. -### Implementation details - -The `rand64` function uses a linear congruential generator, 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. +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. ### Example @@ -111,14 +77,12 @@ SELECT rand64(); ``` ```response -15030268859237645412 +15030268859237645412 -- Note: The actual output will be a random number, not the specific number shown in the example. ``` -**Note:** The actual output will be a random number, not the specific number shown in the example. - ## randCanonical -Returns a random floating-point number of type Float64, evenly distributed within the closed interval. +Returns a random Float64 number. ### Syntax @@ -126,11 +90,11 @@ Returns a random floating-point number of type Float64, evenly distributed withi randCanonical() ``` -### Parameters +### Arguments None. -### Output +### Returned value Returns a Float64 value between 0 (inclusive) and 1 (exclusive). @@ -141,14 +105,12 @@ SELECT randCanonical(); ``` ```response -0.3452178901234567 +0.3452178901234567 - Note: The actual output will be a random Float64 number between 0 and 1, not the specific number shown in the example. ``` -**Note:** The actual output will be a random decimal number between 0 and 1, not the specific number shown in the example. - ## randConstant -Generates a single constant column filled with a random value. Unlike `rand`, `randConstant` ensures the same random value appears in every row of the generated column, making it useful for scenarios requiring a consistent random seed across rows in a single query. +Generates a single constant column filled with a random value. Unlike `rand`, this function ensures the same random value appears in every row of the generated column, making it useful for scenarios requiring a consistent random seed across rows in a single query. ### Syntax @@ -156,11 +118,11 @@ Generates a single constant column filled with a random value. Unlike `rand`, `r randConstant([x]); ``` -### Parameters +### Arguments - **[x] (Optional):** An optional expression that influences the generated random value. Even if provided, the resulting value will still be constant within the same query execution. Different queries using the same expression will likely generate different constant values. -### Output +### Returned value Returns a column of type UInt32 containing the same random value in each row. @@ -200,12 +162,12 @@ Returns a random Float64 drawn uniformly from interval [`min`, `max`]. randUniform(min, max) ``` -### Parameters +### Arguments - `min` - `Float64` - left boundary of the range, - `max` - `Float64` - right boundary of the range. -### Output +### Returned value A random number of type [Float64](/docs/en/sql-reference/data-types/float.md). diff --git a/docs/en/sql-reference/functions/type-conversion-functions.md b/docs/en/sql-reference/functions/type-conversion-functions.md index 37d4ac30648..ea08ffa50e7 100644 --- a/docs/en/sql-reference/functions/type-conversion-functions.md +++ b/docs/en/sql-reference/functions/type-conversion-functions.md @@ -968,7 +968,7 @@ Converts a numeric value to String with the number of fractional digits in the o toDecimalString(number, scale) ``` -**Parameters** +**Arguments** - `number` — Value to be represented as String, [Int, UInt](/docs/en/sql-reference/data-types/int-uint.md), [Float](/docs/en/sql-reference/data-types/float.md), [Decimal](/docs/en/sql-reference/data-types/decimal.md), - `scale` — Number of fractional digits, [UInt8](/docs/en/sql-reference/data-types/int-uint.md). @@ -1261,7 +1261,7 @@ Converts input value `x` to the specified data type `T`. Always returns [Nullabl accurateCastOrNull(x, T) ``` -**Parameters** +**Arguments** - `x` — Input value. - `T` — The name of the returned data type. @@ -1314,7 +1314,7 @@ Converts input value `x` to the specified data type `T`. Returns default type va accurateCastOrDefault(x, T) ``` -**Parameters** +**Arguments** - `x` — Input value. - `T` — The name of the returned data type. @@ -1675,7 +1675,7 @@ Same as [parseDateTimeBestEffort](#parsedatetimebesteffort) function but also pa parseDateTime64BestEffort(time_string [, precision [, time_zone]]) ``` -**Parameters** +**Arguments** - `time_string` — String containing a date or date with time to convert. [String](/docs/en/sql-reference/data-types/string.md). - `precision` — Required precision. `3` — for milliseconds, `6` — for microseconds. Default — `3`. Optional. [UInt8](/docs/en/sql-reference/data-types/int-uint.md). @@ -1990,7 +1990,7 @@ Extracts the timestamp component of a [Snowflake ID](https://en.wikipedia.org/wi snowflakeToDateTime(value[, time_zone]) ``` -**Parameters** +**Arguments** - `value` — Snowflake ID. [Int64](/docs/en/sql-reference/data-types/int-uint.md). - `time_zone` — [Timezone](/docs/en/operations/server-configuration-parameters/settings.md/#server_configuration_parameters-timezone). The function parses `time_string` according to the timezone. Optional. [String](/docs/en/sql-reference/data-types/string.md). @@ -2026,7 +2026,7 @@ Extracts the timestamp component of a [Snowflake ID](https://en.wikipedia.org/wi snowflakeToDateTime64(value[, time_zone]) ``` -**Parameters** +**Arguments** - `value` — Snowflake ID. [Int64](/docs/en/sql-reference/data-types/int-uint.md). - `time_zone` — [Timezone](/docs/en/operations/server-configuration-parameters/settings.md/#server_configuration_parameters-timezone). The function parses `time_string` according to the timezone. Optional. [String](/docs/en/sql-reference/data-types/string.md). @@ -2062,7 +2062,7 @@ Converts a [DateTime](/docs/en/sql-reference/data-types/datetime.md) value to th dateTimeToSnowflake(value) ``` -**Parameters** +**Arguments** - `value` — Date with time. [DateTime](/docs/en/sql-reference/data-types/datetime.md). @@ -2096,7 +2096,7 @@ Convert a [DateTime64](/docs/en/sql-reference/data-types/datetime64.md) to the f dateTime64ToSnowflake(value) ``` -**Parameters** +**Arguments** - `value` — Date with time. [DateTime64](/docs/en/sql-reference/data-types/datetime64.md). diff --git a/docs/en/sql-reference/functions/url-functions.md b/docs/en/sql-reference/functions/url-functions.md index f6871c86c4f..ac81815b47f 100644 --- a/docs/en/sql-reference/functions/url-functions.md +++ b/docs/en/sql-reference/functions/url-functions.md @@ -155,7 +155,7 @@ Configuration example: cutToFirstSignificantSubdomain(URL, TLD) ``` -**Parameters** +**Arguments** - `URL` — URL. [String](../../sql-reference/data-types/string.md). - `TLD` — Custom TLD list name. [String](../../sql-reference/data-types/string.md). @@ -209,7 +209,7 @@ Configuration example: cutToFirstSignificantSubdomainCustomWithWWW(URL, TLD) ``` -**Parameters** +**Arguments** - `URL` — URL. [String](../../sql-reference/data-types/string.md). - `TLD` — Custom TLD list name. [String](../../sql-reference/data-types/string.md). @@ -263,7 +263,7 @@ Configuration example: firstSignificantSubdomainCustom(URL, TLD) ``` -**Parameters** +**Arguments** - `URL` — URL. [String](../../sql-reference/data-types/string.md). - `TLD` — Custom TLD list name. [String](../../sql-reference/data-types/string.md).