mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-19 22:22:00 +00:00
2d2bc052e1
* Typo fix. * Links fix. * Fixed links in docs. * More fixes. * docs/en: cleaning some files * docs/en: cleaning data_types * docs/en: cleaning database_engines * docs/en: cleaning development * docs/en: cleaning getting_started * docs/en: cleaning interfaces * docs/en: cleaning operations * docs/en: cleaning query_lamguage * docs/en: cleaning en * docs/ru: cleaning data_types * docs/ru: cleaning index * docs/ru: cleaning database_engines * docs/ru: cleaning development * docs/ru: cleaning general * docs/ru: cleaning getting_started * docs/ru: cleaning interfaces * docs/ru: cleaning operations * docs/ru: cleaning query_language * docs: cleaning interfaces/http * Update docs/en/data_types/array.md decorated ``` Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/getting_started/example_datasets/nyc_taxi.md fixed typo Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/getting_started/example_datasets/ontime.md fixed typo Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/interfaces/formats.md fixed error Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/table_engines/custom_partitioning_key.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/utils/clickhouse-local.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/dicts/external_dicts_dict_sources.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/utils/clickhouse-local.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/json_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/json_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/other_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/other_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/date_time_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/table_engines/jdbc.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * docs: fixed error * docs: fixed error
36 lines
1.8 KiB
Markdown
36 lines
1.8 KiB
Markdown
# input
|
|
|
|
`input(structure)` - table function that allows effectively convert and insert data sent to the
|
|
server with given structure to the table with another structure.
|
|
|
|
`structure` - structure of data sent to the server in following format `'column1_name column1_type, column2_name column2_type, ...'`.
|
|
For example, `'id UInt32, name String'`.
|
|
|
|
This function can be used only in `INSERT SELECT` query and only once but otherwise behaves like ordinary table function
|
|
(for example, it can be used in subquery, etc.).
|
|
|
|
Data can be sent in any way like for ordinary `INSERT` query and passed in any available [format](../../interfaces/formats.md#formats)
|
|
that must be specified in the end of query (unlike ordinary `INSERT SELECT`).
|
|
|
|
The main feature of this function is that when server receives data from client it simultaneously converts it
|
|
according to the list of expressions in the `SELECT` clause and inserts into the target table. Temporary table
|
|
with all transferred data is not created.
|
|
|
|
**Examples**
|
|
|
|
- Let the `test` table has the following structure `(a String, b String)`
|
|
and data in `data.csv` has a different structure `(col1 String, col2 Date, col3 Int32)`. Query for insert
|
|
data from the `data.csv` into the `test` table with simultaneous conversion looks like this:
|
|
|
|
```bash
|
|
$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT lower(col1), col3 * col3 FROM input('col1 String, col2 Date, col3 Int32') FORMAT CSV";
|
|
```
|
|
|
|
- If `data.csv` contains data of the same structure `test_structure` as the table `test` then these two queries are equal:
|
|
```bash
|
|
$ cat data.csv | clickhouse-client --query="INSERT INTO test FORMAT CSV"
|
|
$ cat data.csv | clickhouse-client --query="INSERT INTO test SELECT * FROM input('test_structure') FORMAT CSV"
|
|
```
|
|
|
|
[Original article](https://clickhouse.yandex/docs/en/query_language/table_functions/input/) <!--hide-->
|