Some fixups

This commit is contained in:
Robert Schulze 2024-03-11 08:34:01 +00:00
parent e98c30c161
commit 27099cedcb
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A
3 changed files with 34 additions and 72 deletions

View File

@ -20,7 +20,9 @@ The random numbers are generated by non-cryptographic algorithms.
## rand ## 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 ### Syntax
@ -28,18 +30,16 @@ Returns a random UInt32 number.
rand() rand()
``` ```
### Parameters Alias: `rand32`
### Arguments
None. None.
### Output ### Returned value
Returns a number of type UInt32. Returns a number of type UInt32.
### Implementation details
Uses a linear congruential generator.
### Example ### Example
```sql ```sql
@ -47,44 +47,12 @@ SELECT rand();
``` ```
```response ```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 ## rand64
Returns a random 64-bit unsigned integer (UInt64) number. Returns a random UInt64 integer (UInt64) number
### Syntax ### Syntax
@ -92,17 +60,15 @@ Returns a random 64-bit unsigned integer (UInt64) number.
rand64() rand64()
``` ```
### Parameters ### Arguments
None. 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 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.
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.
### Example ### Example
@ -111,14 +77,12 @@ SELECT rand64();
``` ```
```response ```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 ## randCanonical
Returns a random floating-point number of type Float64, evenly distributed within the closed interval. Returns a random Float64 number.
### Syntax ### Syntax
@ -126,11 +90,11 @@ Returns a random floating-point number of type Float64, evenly distributed withi
randCanonical() randCanonical()
``` ```
### Parameters ### Arguments
None. None.
### Output ### Returned value
Returns a Float64 value between 0 (inclusive) and 1 (exclusive). Returns a Float64 value between 0 (inclusive) and 1 (exclusive).
@ -141,14 +105,12 @@ SELECT randCanonical();
``` ```
```response ```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 ## 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 ### Syntax
@ -156,11 +118,11 @@ Generates a single constant column filled with a random value. Unlike `rand`, `r
randConstant([x]); 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. - **[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. 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) randUniform(min, max)
``` ```
### Parameters ### Arguments
- `min` - `Float64` - left boundary of the range, - `min` - `Float64` - left boundary of the range,
- `max` - `Float64` - right 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). A random number of type [Float64](/docs/en/sql-reference/data-types/float.md).

View File

@ -968,7 +968,7 @@ Converts a numeric value to String with the number of fractional digits in the o
toDecimalString(number, scale) 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), - `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). - `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) accurateCastOrNull(x, T)
``` ```
**Parameters** **Arguments**
- `x` — Input value. - `x` — Input value.
- `T` — The name of the returned data type. - `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) accurateCastOrDefault(x, T)
``` ```
**Parameters** **Arguments**
- `x` — Input value. - `x` — Input value.
- `T` — The name of the returned data type. - `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]]) 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). - `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). - `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]) snowflakeToDateTime(value[, time_zone])
``` ```
**Parameters** **Arguments**
- `value` — Snowflake ID. [Int64](/docs/en/sql-reference/data-types/int-uint.md). - `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). - `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]) snowflakeToDateTime64(value[, time_zone])
``` ```
**Parameters** **Arguments**
- `value` — Snowflake ID. [Int64](/docs/en/sql-reference/data-types/int-uint.md). - `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). - `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) dateTimeToSnowflake(value)
``` ```
**Parameters** **Arguments**
- `value` — Date with time. [DateTime](/docs/en/sql-reference/data-types/datetime.md). - `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) dateTime64ToSnowflake(value)
``` ```
**Parameters** **Arguments**
- `value` — Date with time. [DateTime64](/docs/en/sql-reference/data-types/datetime64.md). - `value` — Date with time. [DateTime64](/docs/en/sql-reference/data-types/datetime64.md).

View File

@ -155,7 +155,7 @@ Configuration example:
cutToFirstSignificantSubdomain(URL, TLD) cutToFirstSignificantSubdomain(URL, TLD)
``` ```
**Parameters** **Arguments**
- `URL` — URL. [String](../../sql-reference/data-types/string.md). - `URL` — URL. [String](../../sql-reference/data-types/string.md).
- `TLD` — Custom TLD list name. [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) cutToFirstSignificantSubdomainCustomWithWWW(URL, TLD)
``` ```
**Parameters** **Arguments**
- `URL` — URL. [String](../../sql-reference/data-types/string.md). - `URL` — URL. [String](../../sql-reference/data-types/string.md).
- `TLD` — Custom TLD list name. [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) firstSignificantSubdomainCustom(URL, TLD)
``` ```
**Parameters** **Arguments**
- `URL` — URL. [String](../../sql-reference/data-types/string.md). - `URL` — URL. [String](../../sql-reference/data-types/string.md).
- `TLD` — Custom TLD list name. [String](../../sql-reference/data-types/string.md). - `TLD` — Custom TLD list name. [String](../../sql-reference/data-types/string.md).