mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Merge branch 'master' into async-loader-waiters-limit
This commit is contained in:
commit
294526e772
@ -19,7 +19,7 @@ empty([x])
|
||||
An array is considered empty if it does not contain any elements.
|
||||
|
||||
:::note
|
||||
Can be optimized by enabling the [optimize_functions_to_subcolumns](../../operations/settings/settings.md#optimize-functions-to-subcolumns) setting. With `optimize_functions_to_subcolumns = 1` the function reads only [size0](../../sql-reference/data-types/array.md#array-size) subcolumn instead of reading and processing the whole array column. The query `SELECT empty(arr) FROM TABLE;` transforms to `SELECT arr.size0 = 0 FROM TABLE;`.
|
||||
Can be optimized by enabling the [`optimize_functions_to_subcolumns` setting](../../operations/settings/settings.md#optimize-functions-to-subcolumns). With `optimize_functions_to_subcolumns = 1` the function reads only [size0](../../sql-reference/data-types/array.md#array-size) subcolumn instead of reading and processing the whole array column. The query `SELECT empty(arr) FROM TABLE;` transforms to `SELECT arr.size0 = 0 FROM TABLE;`.
|
||||
:::
|
||||
|
||||
The function also works for [strings](string-functions.md#empty) or [UUID](uuid-functions.md#empty).
|
||||
@ -104,17 +104,416 @@ Can be optimized by enabling the [optimize_functions_to_subcolumns](../../operat
|
||||
|
||||
Alias: `OCTET_LENGTH`
|
||||
|
||||
## emptyArrayUInt8, emptyArrayUInt16, emptyArrayUInt32, emptyArrayUInt64
|
||||
## emptyArrayUInt8
|
||||
|
||||
## emptyArrayInt8, emptyArrayInt16, emptyArrayInt32, emptyArrayInt64
|
||||
Returns an empty UInt8 array.
|
||||
|
||||
## emptyArrayFloat32, emptyArrayFloat64
|
||||
**Syntax**
|
||||
|
||||
## emptyArrayDate, emptyArrayDateTime
|
||||
```sql
|
||||
emptyArrayUInt8()
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayUInt8();
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
[]
|
||||
```
|
||||
|
||||
## emptyArrayUInt16
|
||||
|
||||
Returns an empty UInt16 array.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
emptyArrayUInt16()
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayUInt16();
|
||||
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
[]
|
||||
```
|
||||
|
||||
## emptyArrayUInt32
|
||||
|
||||
Returns an empty UInt32 array.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
emptyArrayUInt32()
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayUInt32();
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
[]
|
||||
```
|
||||
|
||||
## emptyArrayUInt64
|
||||
|
||||
Returns an empty UInt64 array.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
emptyArrayUInt64()
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayUInt64();
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
[]
|
||||
```
|
||||
|
||||
## emptyArrayInt8
|
||||
|
||||
Returns an empty Int8 array.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
emptyArrayInt8()
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayInt8();
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
[]
|
||||
```
|
||||
|
||||
## emptyArrayInt16
|
||||
|
||||
Returns an empty Int16 array.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
emptyArrayInt16()
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayInt16();
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
[]
|
||||
```
|
||||
|
||||
## emptyArrayInt32
|
||||
|
||||
Returns an empty Int32 array.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
emptyArrayInt32()
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayInt32();
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
[]
|
||||
```
|
||||
|
||||
## emptyArrayInt64
|
||||
|
||||
Returns an empty Int64 array.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
emptyArrayInt64()
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayInt64();
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
[]
|
||||
```
|
||||
|
||||
## emptyArrayFloat32
|
||||
|
||||
Returns an empty Float32 array.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
emptyArrayFloat32()
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayFloat32();
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
[]
|
||||
```
|
||||
|
||||
## emptyArrayFloat64
|
||||
|
||||
Returns an empty Float64 array.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
emptyArrayFloat64()
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayFloat64();
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
[]
|
||||
```
|
||||
|
||||
## emptyArrayDate
|
||||
|
||||
Returns an empty Date array.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
emptyArrayDate()
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayDate();
|
||||
```
|
||||
|
||||
## emptyArrayDateTime
|
||||
|
||||
Returns an empty DateTime array.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
[]
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayDateTime();
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
[]
|
||||
```
|
||||
|
||||
## emptyArrayString
|
||||
|
||||
Accepts zero arguments and returns an empty array of the appropriate type.
|
||||
Returns an empty String array.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
emptyArrayString()
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
None.
|
||||
|
||||
**Returned value**
|
||||
|
||||
An empty array.
|
||||
|
||||
**Examples**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT emptyArrayString();
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
[]
|
||||
```
|
||||
|
||||
## emptyArrayToSingle
|
||||
|
||||
|
@ -11,79 +11,173 @@ elimination](../../sql-reference/functions/index.md#common-subexpression-elimina
|
||||
function return different random values.
|
||||
|
||||
Related content
|
||||
|
||||
- Blog: [Generating random data in ClickHouse](https://clickhouse.com/blog/generating-random-test-distribution-data-for-clickhouse)
|
||||
|
||||
:::note
|
||||
The random numbers are generated by non-cryptographic algorithms.
|
||||
:::
|
||||
|
||||
## rand, rand32
|
||||
## rand
|
||||
|
||||
Returns a random UInt32 number, evenly distributed across the range of all possible UInt32 numbers.
|
||||
Returns a random UInt32 number with uniform distribution.
|
||||
|
||||
Uses a linear congruential generator.
|
||||
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
|
||||
|
||||
```sql
|
||||
rand()
|
||||
```
|
||||
|
||||
Alias: `rand32`
|
||||
|
||||
### Arguments
|
||||
|
||||
None.
|
||||
|
||||
### Returned value
|
||||
|
||||
Returns a number of type UInt32.
|
||||
|
||||
### Example
|
||||
|
||||
```sql
|
||||
SELECT rand();
|
||||
```
|
||||
|
||||
```response
|
||||
1569354847 -- Note: The actual output will be a random number, not the specific number shown in the example
|
||||
```
|
||||
|
||||
## rand64
|
||||
|
||||
Returns a random UInt64 number, evenly distributed across the range of all possible UInt64 numbers.
|
||||
Returns a random UInt64 integer (UInt64) number
|
||||
|
||||
Uses a linear congruential generator.
|
||||
### Syntax
|
||||
|
||||
```sql
|
||||
rand64()
|
||||
```
|
||||
|
||||
### Arguments
|
||||
|
||||
None.
|
||||
|
||||
### Returned value
|
||||
|
||||
Returns a number UInt64 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.
|
||||
|
||||
### Example
|
||||
|
||||
```sql
|
||||
SELECT rand64();
|
||||
```
|
||||
|
||||
```response
|
||||
15030268859237645412 -- Note: The actual output will be a random number, not the specific number shown in the example.
|
||||
```
|
||||
|
||||
## randCanonical
|
||||
|
||||
Returns a random Float64 value, evenly distributed in interval [0, 1).
|
||||
Returns a random Float64 number.
|
||||
|
||||
### Syntax
|
||||
|
||||
```sql
|
||||
randCanonical()
|
||||
```
|
||||
|
||||
### Arguments
|
||||
|
||||
None.
|
||||
|
||||
### Returned value
|
||||
|
||||
Returns a Float64 value between 0 (inclusive) and 1 (exclusive).
|
||||
|
||||
### Example
|
||||
|
||||
```sql
|
||||
SELECT randCanonical();
|
||||
```
|
||||
|
||||
```response
|
||||
0.3452178901234567 - Note: The actual output will be a random Float64 number between 0 and 1, not the specific number shown in the example.
|
||||
```
|
||||
|
||||
## randConstant
|
||||
|
||||
Like `rand` but produces a constant column with a random value.
|
||||
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.
|
||||
|
||||
**Example**
|
||||
### Syntax
|
||||
|
||||
``` sql
|
||||
SELECT rand(), rand(1), rand(number), randConstant(), randConstant(1), randConstant(number)
|
||||
FROM numbers(3)
|
||||
```sql
|
||||
randConstant([x]);
|
||||
```
|
||||
|
||||
Result:
|
||||
### Arguments
|
||||
|
||||
``` result
|
||||
┌─────rand()─┬────rand(1)─┬─rand(number)─┬─randConstant()─┬─randConstant(1)─┬─randConstant(number)─┐
|
||||
│ 3047369878 │ 4132449925 │ 4044508545 │ 2740811946 │ 4229401477 │ 1924032898 │
|
||||
│ 2938880146 │ 1267722397 │ 4154983056 │ 2740811946 │ 4229401477 │ 1924032898 │
|
||||
│ 956619638 │ 4238287282 │ 1104342490 │ 2740811946 │ 4229401477 │ 1924032898 │
|
||||
└────────────┴────────────┴──────────────┴────────────────┴─────────────────┴──────────────────────┘
|
||||
- **[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.
|
||||
|
||||
### Returned value
|
||||
|
||||
Returns a column of type UInt32 containing the same random value in each row.
|
||||
|
||||
### Implementation details
|
||||
|
||||
The actual output will be different for each query execution, even with the same optional expression. The optional parameter may not significantly change the generated value compared to using `randConstant` alone.
|
||||
|
||||
### Examples
|
||||
|
||||
```sql
|
||||
SELECT randConstant() AS random_value;
|
||||
```
|
||||
|
||||
```response
|
||||
| random_value |
|
||||
|--------------|
|
||||
| 1234567890 |
|
||||
```
|
||||
|
||||
```sql
|
||||
SELECT randConstant(10) AS random_value;
|
||||
```
|
||||
|
||||
```response
|
||||
| random_value |
|
||||
|--------------|
|
||||
| 9876543210 |
|
||||
```
|
||||
|
||||
## randUniform
|
||||
|
||||
Returns a random Float64 drawn uniformly from interval [`min`, `max`) ([continuous uniform distribution](https://en.wikipedia.org/wiki/Continuous_uniform_distribution)).
|
||||
Returns a random Float64 drawn uniformly from interval [`min`, `max`].
|
||||
|
||||
**Syntax**
|
||||
### Syntax
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randUniform(min, max)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
### Arguments
|
||||
|
||||
- `min` - `Float64` - left boundary of the range,
|
||||
- `max` - `Float64` - right boundary of the range.
|
||||
|
||||
**Returned value**
|
||||
### Returned value
|
||||
|
||||
- Random number.
|
||||
A random number of type [Float64](/docs/en/sql-reference/data-types/float.md).
|
||||
|
||||
Type: [Float64](/docs/en/sql-reference/data-types/float.md).
|
||||
### Example
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT randUniform(5.5, 10) FROM numbers(5)
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` result
|
||||
```response
|
||||
┌─randUniform(5.5, 10)─┐
|
||||
│ 8.094978491443102 │
|
||||
│ 7.3181248914450885 │
|
||||
@ -99,7 +193,7 @@ Returns a random Float64 drawn from a [normal distribution](https://en.wikipedia
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randNormal(mean, variance)
|
||||
```
|
||||
|
||||
@ -116,13 +210,13 @@ Type: [Float64](/docs/en/sql-reference/data-types/float.md).
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT randNormal(10, 2) FROM numbers(5)
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` result
|
||||
```result
|
||||
┌──randNormal(10, 2)─┐
|
||||
│ 13.389228911709653 │
|
||||
│ 8.622949707401295 │
|
||||
@ -138,7 +232,7 @@ Returns a random Float64 drawn from a [log-normal distribution](https://en.wikip
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randLogNormal(mean, variance)
|
||||
```
|
||||
|
||||
@ -155,13 +249,13 @@ Type: [Float64](/docs/en/sql-reference/data-types/float.md).
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT randLogNormal(100, 5) FROM numbers(5)
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` result
|
||||
```result
|
||||
┌─randLogNormal(100, 5)─┐
|
||||
│ 1.295699673937363e48 │
|
||||
│ 9.719869109186684e39 │
|
||||
@ -177,7 +271,7 @@ Returns a random UInt64 drawn from a [binomial distribution](https://en.wikipedi
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randBinomial(experiments, probability)
|
||||
```
|
||||
|
||||
@ -194,13 +288,13 @@ Type: [UInt64](/docs/en/sql-reference/data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT randBinomial(100, .75) FROM numbers(5)
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` result
|
||||
```result
|
||||
┌─randBinomial(100, 0.75)─┐
|
||||
│ 74 │
|
||||
│ 78 │
|
||||
@ -216,7 +310,7 @@ Returns a random UInt64 drawn from a [negative binomial distribution](https://en
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randNegativeBinomial(experiments, probability)
|
||||
```
|
||||
|
||||
@ -233,13 +327,13 @@ Type: [UInt64](/docs/en/sql-reference/data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT randNegativeBinomial(100, .75) FROM numbers(5)
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` result
|
||||
```result
|
||||
┌─randNegativeBinomial(100, 0.75)─┐
|
||||
│ 33 │
|
||||
│ 32 │
|
||||
@ -255,7 +349,7 @@ Returns a random UInt64 drawn from a [Poisson distribution](https://en.wikipedia
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randPoisson(n)
|
||||
```
|
||||
|
||||
@ -271,13 +365,13 @@ Type: [UInt64](/docs/en/sql-reference/data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT randPoisson(10) FROM numbers(5)
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` result
|
||||
```result
|
||||
┌─randPoisson(10)─┐
|
||||
│ 8 │
|
||||
│ 8 │
|
||||
@ -293,7 +387,7 @@ Returns a random UInt64 drawn from a [Bernoulli distribution](https://en.wikiped
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randBernoulli(probability)
|
||||
```
|
||||
|
||||
@ -309,13 +403,13 @@ Type: [UInt64](/docs/en/sql-reference/data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT randBernoulli(.75) FROM numbers(5)
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` result
|
||||
```result
|
||||
┌─randBernoulli(0.75)─┐
|
||||
│ 1 │
|
||||
│ 1 │
|
||||
@ -331,7 +425,7 @@ Returns a random Float64 drawn from a [exponential distribution](https://en.wiki
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randExponential(lambda)
|
||||
```
|
||||
|
||||
@ -347,13 +441,13 @@ Type: [Float64](/docs/en/sql-reference/data-types/float.md).
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT randExponential(1/10) FROM numbers(5)
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` result
|
||||
```result
|
||||
┌─randExponential(divide(1, 10))─┐
|
||||
│ 44.71628934340778 │
|
||||
│ 4.211013337903262 │
|
||||
@ -369,7 +463,7 @@ Returns a random Float64 drawn from a [Chi-square distribution](https://en.wikip
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randChiSquared(degree_of_freedom)
|
||||
```
|
||||
|
||||
@ -385,13 +479,13 @@ Type: [Float64](/docs/en/sql-reference/data-types/float.md).
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT randChiSquared(10) FROM numbers(5)
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` result
|
||||
```result
|
||||
┌─randChiSquared(10)─┐
|
||||
│ 10.015463656521543 │
|
||||
│ 9.621799919882768 │
|
||||
@ -407,7 +501,7 @@ Returns a random Float64 drawn from a [Student's t-distribution](https://en.wiki
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randStudentT(degree_of_freedom)
|
||||
```
|
||||
|
||||
@ -423,13 +517,13 @@ Type: [Float64](/docs/en/sql-reference/data-types/float.md).
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT randStudentT(10) FROM numbers(5)
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` result
|
||||
```result
|
||||
┌─────randStudentT(10)─┐
|
||||
│ 1.2217309938538725 │
|
||||
│ 1.7941971681200541 │
|
||||
@ -445,7 +539,7 @@ Returns a random Float64 drawn from a [F-distribution](https://en.wikipedia.org/
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randFisherF(d1, d2)
|
||||
```
|
||||
|
||||
@ -462,13 +556,13 @@ Type: [Float64](/docs/en/sql-reference/data-types/float.md).
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT randFisherF(10, 3) FROM numbers(5)
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` result
|
||||
```result
|
||||
┌──randFisherF(10, 3)─┐
|
||||
│ 7.286287504216609 │
|
||||
│ 0.26590779413050386 │
|
||||
@ -484,7 +578,7 @@ Generates a string of the specified length filled with random bytes (including z
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randomString(length)
|
||||
```
|
||||
|
||||
@ -502,13 +596,13 @@ Type: [String](../../sql-reference/data-types/string.md).
|
||||
|
||||
Query:
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT randomString(30) AS str, length(str) AS len FROM numbers(2) FORMAT Vertical;
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` text
|
||||
```text
|
||||
Row 1:
|
||||
──────
|
||||
str: 3 G : pT ?w тi k aV f6
|
||||
@ -526,7 +620,7 @@ Generates a binary string of the specified length filled with random bytes (incl
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randomFixedString(length);
|
||||
```
|
||||
|
||||
@ -563,7 +657,7 @@ If you pass `length < 0`, the behavior of the function is undefined.
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randomPrintableASCII(length)
|
||||
```
|
||||
|
||||
@ -579,11 +673,11 @@ Type: [String](../../sql-reference/data-types/string.md)
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT number, randomPrintableASCII(30) as str, length(str) FROM system.numbers LIMIT 3
|
||||
```
|
||||
|
||||
``` text
|
||||
```text
|
||||
┌─number─┬─str────────────────────────────┬─length(randomPrintableASCII(30))─┐
|
||||
│ 0 │ SuiCOSTvC0csfABSw=UcSzp2.`rv8x │ 30 │
|
||||
│ 1 │ 1Ag NlJ &RCN:*>HVPG;PE-nO"SUFD │ 30 │
|
||||
@ -597,7 +691,7 @@ Generates a random string of a specified length. Result string contains valid UT
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
randomStringUTF8(length);
|
||||
```
|
||||
|
||||
@ -635,11 +729,12 @@ Flips the bits of String or FixedString `s`, each with probability `prob`.
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
fuzzBits(s, prob)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `s` - `String` or `FixedString`,
|
||||
- `prob` - constant `Float32/64` between 0.0 and 1.0.
|
||||
|
||||
@ -649,14 +744,14 @@ Fuzzed string with same type as `s`.
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
```sql
|
||||
SELECT fuzzBits(materialize('abacaba'), 0.1)
|
||||
FROM numbers(3)
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
``` result
|
||||
```result
|
||||
┌─fuzzBits(materialize('abacaba'), 0.1)─┐
|
||||
│ abaaaja │
|
||||
│ a*cjab+ │
|
||||
|
@ -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).
|
||||
|
||||
|
@ -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).
|
||||
|
@ -2111,8 +2111,7 @@ void InterpreterSelectQuery::applyFiltersToPrewhereInAnalysis(ExpressionAnalysis
|
||||
if (does_storage_support_prewhere && shouldMoveToPrewhere())
|
||||
{
|
||||
/// Execute row level filter in prewhere as a part of "move to prewhere" optimization.
|
||||
analysis.prewhere_info
|
||||
= std::make_shared<PrewhereInfo>(std::move(analysis.filter_info->actions), std::move(analysis.filter_info->column_name));
|
||||
analysis.prewhere_info = std::make_shared<PrewhereInfo>(analysis.filter_info->actions, analysis.filter_info->column_name);
|
||||
analysis.prewhere_info->prewhere_actions->projectInput(false);
|
||||
analysis.prewhere_info->remove_prewhere_column = analysis.filter_info->do_remove_column;
|
||||
analysis.prewhere_info->need_filter = true;
|
||||
@ -2122,8 +2121,8 @@ void InterpreterSelectQuery::applyFiltersToPrewhereInAnalysis(ExpressionAnalysis
|
||||
else
|
||||
{
|
||||
/// Add row level security actions to prewhere.
|
||||
analysis.prewhere_info->row_level_filter = std::move(analysis.filter_info->actions);
|
||||
analysis.prewhere_info->row_level_column_name = std::move(analysis.filter_info->column_name);
|
||||
analysis.prewhere_info->row_level_filter = analysis.filter_info->actions;
|
||||
analysis.prewhere_info->row_level_column_name = analysis.filter_info->column_name;
|
||||
analysis.prewhere_info->row_level_filter->projectInput(false);
|
||||
analysis.filter_info = nullptr;
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
DROP POLICY IF EXISTS url_na_log_policy0 ON url_na_log;
|
||||
DROP TABLE IF EXISTS url_na_log;
|
||||
|
||||
CREATE TABLE url_na_log
|
||||
(
|
||||
`SiteId` UInt32,
|
||||
`DateVisit` Date
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
PRIMARY KEY SiteId
|
||||
ORDER BY (SiteId, DateVisit)
|
||||
SETTINGS index_granularity = 1000, min_bytes_for_wide_part = 0;
|
||||
|
||||
CREATE ROW POLICY url_na_log_policy0 ON url_na_log FOR SELECT USING (DateVisit < '2022-08-11') OR (DateVisit > '2022-08-19') TO default;
|
||||
|
||||
INSERT INTO url_na_log
|
||||
SETTINGS max_insert_block_size = 200000
|
||||
SELECT
|
||||
209,
|
||||
CAST('2022-08-09', 'Date') + toIntervalDay(intDiv(number, 10000))
|
||||
FROM numbers(130000)
|
||||
SETTINGS max_insert_block_size = 200000;
|
||||
|
||||
EXPLAIN ESTIMATE
|
||||
SELECT count()
|
||||
FROM url_na_log
|
||||
PREWHERE (DateVisit >= toFixedString('2022-08-10', 10)) AND (DateVisit <= '2022-08-20')
|
||||
SETTINGS max_block_size = 1048576, max_threads = 1, allow_experimental_parallel_reading_from_replicas = 1, parallel_replicas_for_non_replicated_merge_tree = 1, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', max_parallel_replicas = 3, parallel_replicas_min_number_of_rows_per_replica=10000;
|
||||
|
||||
DROP POLICY url_na_log_policy0 ON url_na_log;
|
||||
DROP TABLE url_na_log;
|
Loading…
Reference in New Issue
Block a user