mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Move fromReadable* docs after docs of formatReadable* functions
This commit is contained in:
parent
56e423f379
commit
81ca448d6b
@ -794,6 +794,102 @@ Result:
|
|||||||
└────────────────┴────────────┘
|
└────────────────┴────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## formatReadableQuantity
|
||||||
|
|
||||||
|
Given a number, this function returns a rounded number with suffix (thousand, million, billion, etc.) as string.
|
||||||
|
|
||||||
|
**Syntax**
|
||||||
|
|
||||||
|
```sql
|
||||||
|
formatReadableQuantity(x)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
Query:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
arrayJoin([1024, 1234 * 1000, (4567 * 1000) * 1000, 98765432101234]) AS number,
|
||||||
|
formatReadableQuantity(number) AS number_for_humans
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
```text
|
||||||
|
┌─────────number─┬─number_for_humans─┐
|
||||||
|
│ 1024 │ 1.02 thousand │
|
||||||
|
│ 1234000 │ 1.23 million │
|
||||||
|
│ 4567000000 │ 4.57 billion │
|
||||||
|
│ 98765432101234 │ 98.77 trillion │
|
||||||
|
└────────────────┴───────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
## formatReadableTimeDelta
|
||||||
|
|
||||||
|
Given a time interval (delta) in seconds, this function returns a time delta with year/month/day/hour/minute/second/millisecond/microsecond/nanosecond as string.
|
||||||
|
|
||||||
|
**Syntax**
|
||||||
|
|
||||||
|
```sql
|
||||||
|
formatReadableTimeDelta(column[, maximum_unit, minimum_unit])
|
||||||
|
```
|
||||||
|
|
||||||
|
**Arguments**
|
||||||
|
|
||||||
|
- `column` — A column with a numeric time delta.
|
||||||
|
- `maximum_unit` — Optional. Maximum unit to show.
|
||||||
|
- Acceptable values: `nanoseconds`, `microseconds`, `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `months`, `years`.
|
||||||
|
- Default value: `years`.
|
||||||
|
- `minimum_unit` — Optional. Minimum unit to show. All smaller units are truncated.
|
||||||
|
- Acceptable values: `nanoseconds`, `microseconds`, `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `months`, `years`.
|
||||||
|
- If explicitly specified value is bigger than `maximum_unit`, an exception will be thrown.
|
||||||
|
- Default value: `seconds` if `maximum_unit` is `seconds` or bigger, `nanoseconds` otherwise.
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
arrayJoin([100, 12345, 432546534]) AS elapsed,
|
||||||
|
formatReadableTimeDelta(elapsed) AS time_delta
|
||||||
|
```
|
||||||
|
|
||||||
|
```text
|
||||||
|
┌────elapsed─┬─time_delta ─────────────────────────────────────────────────────┐
|
||||||
|
│ 100 │ 1 minute and 40 seconds │
|
||||||
|
│ 12345 │ 3 hours, 25 minutes and 45 seconds │
|
||||||
|
│ 432546534 │ 13 years, 8 months, 17 days, 7 hours, 48 minutes and 54 seconds │
|
||||||
|
└────────────┴─────────────────────────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
arrayJoin([100, 12345, 432546534]) AS elapsed,
|
||||||
|
formatReadableTimeDelta(elapsed, 'minutes') AS time_delta
|
||||||
|
```
|
||||||
|
|
||||||
|
```text
|
||||||
|
┌────elapsed─┬─time_delta ─────────────────────────────────────────────────────┐
|
||||||
|
│ 100 │ 1 minute and 40 seconds │
|
||||||
|
│ 12345 │ 205 minutes and 45 seconds │
|
||||||
|
│ 432546534 │ 7209108 minutes and 54 seconds │
|
||||||
|
└────────────┴─────────────────────────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
arrayJoin([100, 12345, 432546534.00000006]) AS elapsed,
|
||||||
|
formatReadableTimeDelta(elapsed, 'minutes', 'nanoseconds') AS time_delta
|
||||||
|
```
|
||||||
|
|
||||||
|
```text
|
||||||
|
┌────────────elapsed─┬─time_delta─────────────────────────────────────┐
|
||||||
|
│ 100 │ 1 minute and 40 seconds │
|
||||||
|
│ 12345 │ 205 minutes and 45 seconds │
|
||||||
|
│ 432546534.00000006 │ 7209108 minutes, 54 seconds and 60 nanoseconds │
|
||||||
|
└────────────────────┴────────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
## fromReadableSize
|
## fromReadableSize
|
||||||
|
|
||||||
Given a string containing the readable representation of a byte size with ISO/IEC 80000-13 units this function returns the corresponding number of bytes.
|
Given a string containing the readable representation of a byte size with ISO/IEC 80000-13 units this function returns the corresponding number of bytes.
|
||||||
@ -1008,102 +1104,6 @@ SELECT
|
|||||||
└────────────────┴─────────┘
|
└────────────────┴─────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
## formatReadableQuantity
|
|
||||||
|
|
||||||
Given a number, this function returns a rounded number with suffix (thousand, million, billion, etc.) as string.
|
|
||||||
|
|
||||||
**Syntax**
|
|
||||||
|
|
||||||
```sql
|
|
||||||
formatReadableQuantity(x)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
Query:
|
|
||||||
|
|
||||||
```sql
|
|
||||||
SELECT
|
|
||||||
arrayJoin([1024, 1234 * 1000, (4567 * 1000) * 1000, 98765432101234]) AS number,
|
|
||||||
formatReadableQuantity(number) AS number_for_humans
|
|
||||||
```
|
|
||||||
|
|
||||||
Result:
|
|
||||||
|
|
||||||
```text
|
|
||||||
┌─────────number─┬─number_for_humans─┐
|
|
||||||
│ 1024 │ 1.02 thousand │
|
|
||||||
│ 1234000 │ 1.23 million │
|
|
||||||
│ 4567000000 │ 4.57 billion │
|
|
||||||
│ 98765432101234 │ 98.77 trillion │
|
|
||||||
└────────────────┴───────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
## formatReadableTimeDelta
|
|
||||||
|
|
||||||
Given a time interval (delta) in seconds, this function returns a time delta with year/month/day/hour/minute/second/millisecond/microsecond/nanosecond as string.
|
|
||||||
|
|
||||||
**Syntax**
|
|
||||||
|
|
||||||
```sql
|
|
||||||
formatReadableTimeDelta(column[, maximum_unit, minimum_unit])
|
|
||||||
```
|
|
||||||
|
|
||||||
**Arguments**
|
|
||||||
|
|
||||||
- `column` — A column with a numeric time delta.
|
|
||||||
- `maximum_unit` — Optional. Maximum unit to show.
|
|
||||||
- Acceptable values: `nanoseconds`, `microseconds`, `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `months`, `years`.
|
|
||||||
- Default value: `years`.
|
|
||||||
- `minimum_unit` — Optional. Minimum unit to show. All smaller units are truncated.
|
|
||||||
- Acceptable values: `nanoseconds`, `microseconds`, `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `months`, `years`.
|
|
||||||
- If explicitly specified value is bigger than `maximum_unit`, an exception will be thrown.
|
|
||||||
- Default value: `seconds` if `maximum_unit` is `seconds` or bigger, `nanoseconds` otherwise.
|
|
||||||
|
|
||||||
**Example**
|
|
||||||
|
|
||||||
```sql
|
|
||||||
SELECT
|
|
||||||
arrayJoin([100, 12345, 432546534]) AS elapsed,
|
|
||||||
formatReadableTimeDelta(elapsed) AS time_delta
|
|
||||||
```
|
|
||||||
|
|
||||||
```text
|
|
||||||
┌────elapsed─┬─time_delta ─────────────────────────────────────────────────────┐
|
|
||||||
│ 100 │ 1 minute and 40 seconds │
|
|
||||||
│ 12345 │ 3 hours, 25 minutes and 45 seconds │
|
|
||||||
│ 432546534 │ 13 years, 8 months, 17 days, 7 hours, 48 minutes and 54 seconds │
|
|
||||||
└────────────┴─────────────────────────────────────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
```sql
|
|
||||||
SELECT
|
|
||||||
arrayJoin([100, 12345, 432546534]) AS elapsed,
|
|
||||||
formatReadableTimeDelta(elapsed, 'minutes') AS time_delta
|
|
||||||
```
|
|
||||||
|
|
||||||
```text
|
|
||||||
┌────elapsed─┬─time_delta ─────────────────────────────────────────────────────┐
|
|
||||||
│ 100 │ 1 minute and 40 seconds │
|
|
||||||
│ 12345 │ 205 minutes and 45 seconds │
|
|
||||||
│ 432546534 │ 7209108 minutes and 54 seconds │
|
|
||||||
└────────────┴─────────────────────────────────────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
```sql
|
|
||||||
SELECT
|
|
||||||
arrayJoin([100, 12345, 432546534.00000006]) AS elapsed,
|
|
||||||
formatReadableTimeDelta(elapsed, 'minutes', 'nanoseconds') AS time_delta
|
|
||||||
```
|
|
||||||
|
|
||||||
```text
|
|
||||||
┌────────────elapsed─┬─time_delta─────────────────────────────────────┐
|
|
||||||
│ 100 │ 1 minute and 40 seconds │
|
|
||||||
│ 12345 │ 205 minutes and 45 seconds │
|
|
||||||
│ 432546534.00000006 │ 7209108 minutes, 54 seconds and 60 nanoseconds │
|
|
||||||
└────────────────────┴────────────────────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
## parseTimeDelta
|
## parseTimeDelta
|
||||||
|
|
||||||
Parse a sequence of numbers followed by something resembling a time unit.
|
Parse a sequence of numbers followed by something resembling a time unit.
|
||||||
|
Loading…
Reference in New Issue
Block a user