提交 be44a221 编写于 作者: I Ivan Blinkov

Move Utilities out of top level of docs (the location is probably not yet...

Move Utilities out of top level of docs (the location is probably not yet final) + translate couple articles
上级 b4eb91b7
<a name="utils-clickhouse-local"></a>
# clickhouse-local
The `clickhouse-local` program enables you to perform fast processing on local files, without having to deploy and configure the ClickHouse server.
Accepts data that represent tables and queries them using [ClickHouse SQL dialect](../../query_language/queries.md#queries).
`clickhouse-local` uses the same core as ClickHouse server, so it supports most of the features and the same set of formats and table engines.
By default `clickhouse-local` does not have access to data on the same host, but it supports loading server configuration using `--config-file` argument.
<div class="admonition warning">
It is not recommended to load production server configuration into `clickhouse-local` because data can be damaged in case of human error.
</div>
## Usage
Basic usage:
``` bash
clickhouse-local --structure "table_structure" --input-format "format_of_incoming_data" -q "query"
```
Arguments:
- `-S`, `--structure` — table structure for input data.
- `-if`, `--input-format` — input format, `TSV` by default.
- `-f`, `--file` — path to data, `stdin` by default.
- `-q` `--query` — queries to execute with `;` as delimeter.
- `-N`, `--table` — table name where to put output data, `table` by default.
- `-of`, `--format`, `--output-format` — output format, `TSV` by default.
- `--stacktrace` — whether to dump debug output in case of exception.
- `--verbose` — more details on query execution.
- `-s` — disables `stderr` logging.
- `--config-file` — path to configuration file in same format as for ClickHouse server, by default the configuration empty.
- `--help` — arguments references for `clickhouse-local`.
Also there are arguments for each ClickHouse configuration variable which are more commonly used instead of `--config-file`.
## Examples
``` bash
echo -e "1,2\n3,4" | clickhouse-local -S "a Int64, b Int64" -if "CSV" -q "SELECT * FROM table"
Read 2 rows, 32.00 B in 0.000 sec., 5182 rows/sec., 80.97 KiB/sec.
1 2
3 4
```
Previous example is the same as:
``` bash
$ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin); SELECT a, b FROM table; DROP TABLE table"
Read 2 rows, 32.00 B in 0.000 sec., 4987 rows/sec., 77.93 KiB/sec.
1 2
3 4
```
Now let's output memory user for each Unix user:
``` bash
$ ps aux | tail -n +2 | awk '{ printf("%s\t%s\n", $1, $4) }' | clickhouse-local -S "user String, mem Float64" -q "SELECT user, round(sum(mem), 2) as memTotal FROM table GROUP BY user ORDER BY memTotal DESC FORMAT Pretty"
Read 186 rows, 4.15 KiB in 0.035 sec., 5302 rows/sec., 118.34 KiB/sec.
┏━━━━━━━━━━┳━━━━━━━━━━┓
┃ user ┃ memTotal ┃
┡━━━━━━━━━━╇━━━━━━━━━━┩
│ bayonet │ 113.5 │
├──────────┼──────────┤
│ root │ 8.8 │
├──────────┼──────────┤
...
```
<a name="table_engines-file"></a>
# File(InputFormat)
The data source is a file that stores data in one of the supported input formats (TabSeparated, Native, etc.).
Usage examples:
- Data export from ClickHouse to file.
- Convert data from one format to another.
- Updating data in ClickHouse via editing a file on a disk.
## Использование движка в сервере ClickHouse
```
File(Format)
```
`Format` should be supported for either `INSERT` and `SELECT`. For the full list of supported formats see [Formats](../interfaces/formats.md#formats).
ClickHouse does not allow to specify filesystem path for`File`. It will use folder defined by [path](../operations/server_settings/settings.md#server_settings-path) setting in server configuration.
When creating table using `File(Format)` it creates empty subdirectory in that folder. When data is written to that table, it's put into `data.Format` file in that subdirectory.
You may manually create this subfolder and file in server filesystem and then [ATTACH](../query_language/queries.md#queries-attach) it to table information with matching name, so you can query data from that file.
<div class="admonition warning">
Be careful with this funcionality, because ClickHouse does not keep track of external changes to such files. The result of simultaneous writes via ClickHouse and outside of ClickHouse is undefined.
</div>
**Example:**
**1.** Set up the `file_engine_table` table:
```sql
CREATE TABLE file_engine_table (name String, value UInt32) ENGINE=File(TabSeparated)
```
By default ClickHouse will create folder `/var/lib/clickhouse/data/default/file_engine_table`.
**2.** Manually create `/var/lib/clickhouse/data/default/file_engine_table/data.TabSeparated` containing:
```bash
$ cat data.TabSeparated
one 1
two 2
```
**3.** Query the data:
```sql
SELECT * FROM file_engine_table
```
```text
┌─name─┬─value─┐
│ one │ 1 │
│ two │ 2 │
└──────┴───────┘
```
## Using clickhouse-local
In [clickhouse-local](../operations/utils/clickhouse-local.md#utils-clickhouse-local) File engine accepts file path in addition to `Format`. Default input/output streams can be specified using numeric or human-readable names like `0` or `stdin`, `1` or `stdout`.
**Example:**
```bash
$ echo -e "1,2\n3,4" | clickhouse-local -q "CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin); SELECT a, b FROM table; DROP TABLE table"
```
## Details of implemntation
- Reads can be parallel, but not writes
- Not supported:
- `ALTER`
- `SELECT ... SAMPLE`
- Indices
- Replication
<a name="utils-clickhouse-local"></a>
#clickhouse-local
The `clickhouse-local` program enables you to perform fast processing on local files that store tables, without having to deploy and configure the ClickHouse server.
......@@ -153,10 +153,10 @@ pages:
- 'Settings': 'operations/settings/settings.md'
- 'Settings profiles': 'operations/settings/settings_profiles.md'
- 'Utilities':
- 'Introduction': 'utils/index.md'
- 'clickhouse-copier': 'utils/clickhouse-copier.md'
- 'clickhouse-local': 'utils/clickhouse-local.md'
- 'Utilities':
- 'Overview': 'operations/utils/index.md'
- 'clickhouse-copier': 'operations/utils/clickhouse-copier.md'
- 'clickhouse-local': 'operations/utils/clickhouse-local.md'
- 'ClickHouse Development':
# - 'ClickHouse Development': 'development/index.md'
......
......@@ -153,11 +153,10 @@ pages:
- 'Ограничения на сложность запроса': 'operations/settings/query_complexity.md'
- 'Настройки': 'operations/settings/settings.md'
- 'Профили настроек': 'operations/settings/settings_profiles.md'
- 'Утилиты':
- 'Введение': 'utils/index.md'
- 'clickhouse-copier': 'utils/clickhouse-copier.md'
- 'clickhouse-local': 'utils/clickhouse-local.md'
- 'Утилиты':
- 'Введение': 'operations/utils/index.md'
- 'clickhouse-copier': 'operations/utils/clickhouse-copier.md'
- 'clickhouse-local': 'operations/utils/clickhouse-local.md'
- 'ClickHouse Development':
# - 'ClickHouse Development': 'development/index.md'
......
......@@ -20,7 +20,7 @@ system_tables/system.zookeeper.md operations/system_tables.md
formats/capnproto.md formats/interfaces.md
formats/csv.md formats/interfaces.md
formats/csvwithnames.md formats/interfaces.md
formats/index.md formats/interfaces.md
formats.md formats/interfaces.md
formats/json.md formats/interfaces.md
formats/jsoncompact.md formats/interfaces.md
formats/jsoneachrow.md formats/interfaces.md
......@@ -41,3 +41,6 @@ formats/values.md formats/interfaces.md
formats/vertical.md formats/interfaces.md
formats/verticalraw.md formats/interfaces.md
formats/xml.md formats/interfaces.md
utils/clickhouse-copier.md operations/utils/clickhouse-copier.md
utils/clickhouse-local.md operations/utils/clickhouse-local.md
utils.md operations/utils.md
......@@ -2,7 +2,7 @@
# clickhouse-local
Принимает на вход данные, которые можно представить в табличном виде и выполняет над ними операции, заданные на [языке запросов](../query_language/queries.md#queries) ClickHouse.
Принимает на вход данные, которые можно представить в табличном виде и выполняет над ними операции, заданные на [языке запросов](../../query_language/queries.md#queries) ClickHouse.
`clickhouse-local` использует движок сервера ClickHouse, т.е. поддерживает все форматы данных и движки таблиц, с которыми работает ClickHouse, при этом для выполнения операций не требуется запущенный сервер.
......
......@@ -61,7 +61,7 @@ SELECT * FROM file_engine_table
## Использование движка в clickhouse-local
В [clickhouse-local](../utils/clickhouse-local.md#utils-clickhouse-local) движок в качестве параметра принимает не только формат, но и путь к файлу. В том числе можно указать стандартные потоки ввода/вывода цифровым или буквенным обозначением `0` или `stdin`, `1` или `stdout`.
В [clickhouse-local](../operations/utils/clickhouse-local.md#utils-clickhouse-local) движок в качестве параметра принимает не только формат, но и путь к файлу. В том числе можно указать стандартные потоки ввода/вывода цифровым или буквенным обозначением `0` или `stdin`, `1` или `stdout`.
**Пример:**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册