mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
DOCAPI-7438: Update of quantileTiming docs. (#6455)
* Link fix. * DOCAPI-7438: Update of quantileTiming functions docs. * Update docs/en/query_language/agg_functions/reference.md Co-Authored-By: Ivan Blinkov <github@blinkov.ru> * Update docs/en/query_language/agg_functions/reference.md Co-Authored-By: Ivan Blinkov <github@blinkov.ru> * Update docs/en/query_language/agg_functions/reference.md Co-Authored-By: Ivan Blinkov <github@blinkov.ru> * DOCAPI-7438: Clarifications. * DOCAPI-7438: Links fix.
This commit is contained in:
parent
f77c8cd79c
commit
9a245f7930
@ -27,7 +27,7 @@ SELECT 1 - 0.9
|
||||
- Floating-point calculations might result in numbers such as infinity (`Inf`) and "not-a-number" (`NaN`). This should be taken into account when processing the results of calculations.
|
||||
- When parsing floating point numbers from text, the result might not be the nearest machine-representable number.
|
||||
|
||||
## NaN and Inf
|
||||
## NaN and Inf {#data_type-float-nan-inf}
|
||||
|
||||
In contrast to standard SQL, ClickHouse supports the following categories of floating-point numbers:
|
||||
|
||||
|
@ -819,7 +819,7 @@ Creates an array from different argument values. Memory consumption is the same
|
||||
The second version (with the `max_size` parameter) limits the size of the resulting array to `max_size` elements.
|
||||
For example, `groupUniqArray(1)(x)` is equivalent to `[any(x)]`.
|
||||
|
||||
## quantile(level)(x)
|
||||
## quantile(level)(x) {#agg_function-quantile}
|
||||
|
||||
Approximates the `level` quantile. `level` is a constant, a floating-point number from 0 to 1.
|
||||
We recommend using a `level` value in the range of `[0.01, 0.99]`
|
||||
@ -846,27 +846,55 @@ To achieve this, the function takes a second argument – the "determinator". Th
|
||||
|
||||
Don't use this function for calculating timings. There is a more suitable function for this purpose: `quantileTiming`.
|
||||
|
||||
## quantileTiming(level)(x)
|
||||
## quantileTiming {#agg_function-quantiletiming}
|
||||
|
||||
Computes the quantile of 'level' with a fixed precision.
|
||||
Works for numbers. Intended for calculating quantiles of page loading time in milliseconds.
|
||||
Computes the quantile of the specified level with determined precision. The function intended for calculating quantiles of page loading time in milliseconds.
|
||||
|
||||
If the value is greater than 30,000 (a page loading time of more than 30 seconds), the result is equated to 30,000.
|
||||
```
|
||||
quantileTiming(level)(expr)
|
||||
```
|
||||
|
||||
If the total value is not more than about 5670, then the calculation is accurate.
|
||||
**Parameters**
|
||||
|
||||
Otherwise:
|
||||
- `level` — Quantile level. Range: [0, 1].
|
||||
- `expr` — [Expression](../syntax.md#syntax-expressions) returning number in the [Float*](../../data_types/float.md) type. The function expects input values in unix timestamp format in milliseconds, but it doesn't validate format.
|
||||
|
||||
- if the time is less than 1024 ms, then the calculation is accurate.
|
||||
- otherwise the calculation is rounded to a multiple of 16 ms.
|
||||
- If negative values are passed to the function, the behavior is undefined.
|
||||
- If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000.
|
||||
|
||||
When passing negative values to the function, the behavior is undefined.
|
||||
**Accuracy**
|
||||
|
||||
The returned value has the Float32 type. If no values were passed to the function (when using `quantileTimingIf`), 'nan' is returned. The purpose of this is to differentiate these instances from zeros. See the note on sorting NaNs in "ORDER BY clause".
|
||||
The calculation is accurate if:
|
||||
|
||||
The result is determinate (it doesn't depend on the order of query processing).
|
||||
- Total number of values is not more than about 5670.
|
||||
- Total number of values is more than about 5670, but the times of page loading is less than 1024ms.
|
||||
|
||||
For its purpose (calculating quantiles of page loading times), using this function is more effective and the result is more accurate than for the `quantile` function.
|
||||
Otherwise, the result of a calculation is rounded to the value, multiple of 16 ms.
|
||||
|
||||
!! note "Note"
|
||||
For calculating quantiles of page loading times, this function is more effective and accurate compared to [quantile](#agg_function-quantile).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- Quantile of the specified level.
|
||||
|
||||
Type: `Float32`.
|
||||
|
||||
!!! note "Note"
|
||||
If no values were passed to the function (when using `quantileTimingIf`), [NaN](../../data_types/float.md#data_type-float-nan-inf) is returned. The purpose of this is to differentiate these cases from the cases which result in zero. See [ORDER BY clause](../select.md#select-order-by) for the note on sorting `NaN` values.
|
||||
|
||||
The result is deterministic (it doesn't depend on the order of query processing).
|
||||
|
||||
**Example**
|
||||
|
||||
```sql
|
||||
SELECT quantileTiming(0.5)(number / 2) FROM numbers(10)
|
||||
```
|
||||
```text
|
||||
┌─quantileTiming(0.5)(divide(number, 2))─┐
|
||||
│ 2 │
|
||||
└────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## quantileTimingWeighted(level)(x, weight)
|
||||
|
||||
|
@ -32,7 +32,7 @@ SELECT 1 - 0.9
|
||||
- محاسبات Float ممکن اسن نتایجی مثل infinity (`inf`) و "Not-a-number" (`Nan`) داشته باشد. این در هنگام پردازش نتایج محاسبات باید مورد توجه قرار گیرد.
|
||||
- هنگام خواندن اعداد float از سطر ها، نتایج ممکن است نزدیک به اعداد machine-representable نباشد.
|
||||
|
||||
## NaN و Inf
|
||||
## NaN و Inf {#data_type-float-nan-inf}
|
||||
|
||||
در مقابل استاندارد SQL، ClickHouse از موارد زیر مربوط به اعداد float پشتیبانی می کند:
|
||||
|
||||
|
@ -29,7 +29,7 @@ SELECT 1 - 0.9
|
||||
|
||||
- 当一行行阅读浮点数的时候,浮点数的结果可能不是机器最近显示的数值。
|
||||
|
||||
## NaN and Inf
|
||||
## NaN and Inf {#data_type-float-nan-inf}
|
||||
|
||||
与标准SQL相比,ClickHouse 支持以下类别的浮点数:
|
||||
|
||||
|
@ -612,7 +612,7 @@ WHERE于HAVING不同之处在于WHERE在聚合前(GROUP BY)执行,HAVING在聚
|
||||
如果不存在聚合,则不能使用HAVING。
|
||||
|
||||
|
||||
### ORDER BY 子句
|
||||
### ORDER BY 子句 {#select-order-by}
|
||||
|
||||
如果存在ORDER BY 子句,则该子句中必须存在一个表达式列表,表达式列表中每一个表达式都可以分配一个DESC或ASC(排序的方向)。如果没有指明排序的方向,将假定以ASC的方式进行排序。其中ASC表示按照升序排序,DESC按照降序排序。示例:`ORDER BY Visits DESC, SearchPhrase`
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user