mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Update docs about format table function
This commit is contained in:
parent
8e7533fa57
commit
0e7143070e
@ -6,25 +6,28 @@ sidebar_label: format
|
|||||||
|
|
||||||
# format
|
# format
|
||||||
|
|
||||||
Extracts table structure from data and parses it according to specified input format.
|
Parses data from arguments according to specified input format. If structure argument is not specified, it's extracted from the data.
|
||||||
|
|
||||||
**Syntax**
|
**Syntax**
|
||||||
|
|
||||||
``` sql
|
``` sql
|
||||||
format(format_name, data)
|
format(format_name, [structure], data)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Parameters**
|
**Parameters**
|
||||||
|
|
||||||
- `format_name` — The [format](../../interfaces/formats.md#formats) of the data.
|
- `format_name` — The [format](../../interfaces/formats.md#formats) of the data.
|
||||||
|
- `structure` - Structure of the table. Optional. Format 'column1_name column1_type, column2_name column2_type, ...'.
|
||||||
- `data` — String literal or constant expression that returns a string containing data in specified format
|
- `data` — String literal or constant expression that returns a string containing data in specified format
|
||||||
|
|
||||||
**Returned value**
|
**Returned value**
|
||||||
|
|
||||||
A table with data parsed from `data` argument according specified format and extracted schema.
|
A table with data parsed from `data` argument according to specified format and specified or extracted structure.
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
|
Without `structure` argument:
|
||||||
|
|
||||||
**Query:**
|
**Query:**
|
||||||
``` sql
|
``` sql
|
||||||
SELECT * FROM format(JSONEachRow,
|
SELECT * FROM format(JSONEachRow,
|
||||||
@ -67,6 +70,29 @@ $$)
|
|||||||
└──────┴───────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘
|
└──────┴───────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
|
With `structure` argument:
|
||||||
|
|
||||||
|
**Query:**
|
||||||
|
```sql
|
||||||
|
SELECT * FROM format(JSONEachRow, 'a String, b UInt32',
|
||||||
|
$$
|
||||||
|
{"a": "Hello", "b": 111}
|
||||||
|
{"a": "World", "b": 123}
|
||||||
|
{"a": "Hello", "b": 112}
|
||||||
|
{"a": "World", "b": 124}
|
||||||
|
$$)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Result:**
|
||||||
|
```response
|
||||||
|
┌─a─────┬───b─┐
|
||||||
|
│ Hello │ 111 │
|
||||||
|
│ World │ 123 │
|
||||||
|
│ Hello │ 112 │
|
||||||
|
│ World │ 124 │
|
||||||
|
└───────┴─────┘
|
||||||
|
```
|
||||||
|
|
||||||
**See Also**
|
**See Also**
|
||||||
|
|
||||||
- [Formats](../../interfaces/formats.md)
|
- [Formats](../../interfaces/formats.md)
|
||||||
|
Loading…
Reference in New Issue
Block a user