This commit is contained in:
Alexey 2021-07-06 18:55:44 +00:00
parent 9ee9592168
commit 490871cf9f

View File

@ -25,6 +25,17 @@ url(URL, format, structure)
A table with the specified format and structure and with data from the defined `URL`.
**Globs in URL**
Curly brackets in a URL are used to generate a set of shards or specify a failover addresses.
- {*a*,*b*} - any number of variants separated by a comma. This pattern generates address with *a* and address with *b*.
- {*n*..*m*} - a range of numbers. It generates addresses with an increasing indices from *n* to *m*.
- {*0n*..*m*} - a range of numbers with leading zeroes. It preserves leading zeroes in indices.
- {*a*|*b*} - any number of variants separated by a `|`. Specify a failover: variant *b* is used if address with *a* is not available.
Several curly brackets may be used inside a single URL
**Examples**
Getting the first 3 lines of a table that contains columns of `String` and [UInt32](../../sql-reference/data-types/int-uint.md) type from HTTP-server which answers in [CSV](../../interfaces/formats.md#csv) format.
@ -41,4 +52,11 @@ INSERT INTO FUNCTION url('http://127.0.0.1:8123/?query=INSERT+INTO+test_table+FO
SELECT * FROM test_table;
```
This query reads `table-08.csv`, `table-09.csv`, `table-10.csv` from `replica0.local`. If it fails it tries `replica1.local`. `replica2.local` is the last failover option.
``` sql
SELECT * FROM url('https://replica{0|1|2}.local/table-{08..10}.csv', 'CSV', 'column1 String, column2 Uint32') 3;
```
[Original article](https://clickhouse.tech/docs/en/sql-reference/table-functions/url/) <!--hide-->