Some fixes

This commit is contained in:
George 2021-02-02 05:54:38 +03:00
parent 4c9a640ed4
commit 1f6a686f4e
2 changed files with 22 additions and 50 deletions

View File

@ -186,8 +186,6 @@ In ClickHouse, queries are always run on blocks (sets of column parts). This fun
Returns estimation of uncompressed byte size of its arguments in memory.
Use case: suppose you have a service that stores data for multiple clients in one table. Users will pay per data volume. So, you need to implement accounting of users data volume. The function will allow to calculate the data size on per-row basis.
**Syntax**
```sql
@ -244,11 +242,7 @@ ORDER BY key;
INSERT INTO test VALUES(1, 8, 16, 32, 64, -8, -16, -32, -64, 32.32, 64.64);
SELECT key, byteSize(u8) AS `byteSize(UInt8)`, byteSize(u16) AS `byteSize(UInt16)`, byteSize(u32) AS `byteSize(UInt32)`, byteSize(u64) AS `byteSize(UInt64)` FROM test ORDER BY key ASC FORMAT Vertical;
SELECT key, byteSize(i8) AS `byteSize(Int8)`, byteSize(i16) AS `byteSize(Int16)`, byteSize(i32) AS `byteSize(Int32)`, byteSize(i64) AS `byteSize(Int64)` FROM test ORDER BY key ASC FORMAT Vertical;
SELECT key, byteSize(f32) AS `byteSize(Float32)`, byteSize(f64) AS `byteSize(Float64)` FROM test ORDER BY key ASC FORMAT Vertical;
SELECT key, byteSize(u8) AS `byteSize(UInt8)`, byteSize(u16) AS `byteSize(UInt16)`, byteSize(u32) AS `byteSize(UInt32)`, byteSize(u64) AS `byteSize(UInt64)`, byteSize(i8) AS `byteSize(Int8)`, byteSize(i16) AS `byteSize(Int16)`, byteSize(i32) AS `byteSize(Int32)`, byteSize(i64) AS `byteSize(Int64)`, byteSize(f32) AS `byteSize(Float32)`, byteSize(f64) AS `byteSize(Float64)` FROM test ORDER BY key ASC FORMAT Vertical;
```
Result:
@ -261,23 +255,15 @@ byteSize(UInt8): 1
byteSize(UInt16): 2
byteSize(UInt32): 4
byteSize(UInt64): 8
Row 1:
──────
key: 1
byteSize(Int8): 1
byteSize(Int16): 2
byteSize(Int32): 4
byteSize(Int64): 8
Row 1:
──────
key: 1
byteSize(Float32): 4
byteSize(Float64): 8
```
The function can take multiple arguments and will return their combined byte size.
If the function takes multiple arguments, it returns their combined byte size.
Query:

View File

@ -185,9 +185,7 @@ SELECT visibleWidth(NULL)
## byteSize {#function-bytesize}
Возвращает примерный размер аргументов в памяти в байтах в несжатом виде.
Пример использования: в сервисе, хранящим данные для нескольких клиентов в одной таблице, пользователь платит за хранение данных. Поэтому требуется узнать количество памяти, занимаемое ими. Функция позволяет вычислить размер данных для каждой строки.
Возвращает оценку в байтах размера аргументов в памяти в несжатом виде.
**Синтаксис**
@ -245,14 +243,10 @@ ORDER BY key;
INSERT INTO test VALUES(1, 8, 16, 32, 64, -8, -16, -32, -64, 32.32, 64.64);
SELECT key, byteSize(u8) AS `byteSize(UInt8)`, byteSize(u16) AS `byteSize(UInt16)`, byteSize(u32) AS `byteSize(UInt32)`, byteSize(u64) AS `byteSize(UInt64)` FROM test ORDER BY key ASC FORMAT Vertical;
SELECT key, byteSize(i8) AS `byteSize(Int8)`, byteSize(i16) AS `byteSize(Int16)`, byteSize(i32) AS `byteSize(Int32)`, byteSize(i64) AS `byteSize(Int64)` FROM test ORDER BY key ASC FORMAT Vertical;
SELECT key, byteSize(f32) AS `byteSize(Float32)`, byteSize(f64) AS `byteSize(Float64)` FROM test ORDER BY key ASC FORMAT Vertical;
SELECT key, byteSize(u8) AS `byteSize(UInt8)`, byteSize(u16) AS `byteSize(UInt16)`, byteSize(u32) AS `byteSize(UInt32)`, byteSize(u64) AS `byteSize(UInt64)`, byteSize(i8) AS `byteSize(Int8)`, byteSize(i16) AS `byteSize(Int16)`, byteSize(i32) AS `byteSize(Int32)`, byteSize(i64) AS `byteSize(Int64)`, byteSize(f32) AS `byteSize(Float32)`, byteSize(f64) AS `byteSize(Float64)` FROM test ORDER BY key ASC FORMAT Vertical;
```
Результат:
Result:
``` text
Row 1:
@ -262,23 +256,15 @@ byteSize(UInt8): 1
byteSize(UInt16): 2
byteSize(UInt32): 4
byteSize(UInt64): 8
Row 1:
──────
key: 1
byteSize(Int8): 1
byteSize(Int16): 2
byteSize(Int32): 4
byteSize(Int64): 8
Row 1:
──────
key: 1
byteSize(Float32): 4
byteSize(Float64): 8
```
Функция может принимать несколько аргументов и будет возвращать их совокупный размер в байтах.
Если функция принимает несколько аргументов, то она возвращает их совокупный размер в байтах.
Запрос: