ClickHouse/docs/en/sql-reference/table-functions/url.md
Alexey e127110709 Title changed to Globs in Addresses
Section moved to remote() and replaced previous text there.
Created a link from url() to remote().
New settings are mentioned also.
2021-07-15 15:58:47 +00:00

2.1 KiB

toc_priority toc_title
41 url

url

url function creates a table from the URL with given format and structure.

url function may be used in SELECT and INSERT queries on data in URL tables.

Syntax

url(URL, format, structure)

Parameters

  • URL — HTTP or HTTPS server address, which can accept GET or POST requests (for SELECT or INSERT queries correspondingly). Type: String.
  • formatFormat of the data. Type: String.
  • structure — Table structure in 'UserID UInt64, Name String' format. Determines column names and types. Type: String.

Returned value

A table with the specified format and structure and with data from the defined URL.

Globs in URL

Patterns in curly brackets { } are used to generate a set of shards or to specify failover addresses. Supported pattern types and examples see in the description of the remote function. Additionally, character | is used to specify failover addresses. They are iterated in the same order as listed in the pattern. The maximum number of generated addresses is limited by glob_expansion_max_elements setting.

Examples

Getting the first 3 lines of a table that contains columns of String and UInt32 type from HTTP-server which answers in CSV format.

SELECT * FROM url('http://127.0.0.1:12345/', CSV, 'column1 String, column2 UInt32') LIMIT 3;

Inserting data from a URL into a table:

CREATE TABLE test_table (column1 String, column2 UInt32) ENGINE=Memory;
INSERT INTO FUNCTION url('http://127.0.0.1:8123/?query=INSERT+INTO+test_table+FORMAT+CSV', 'CSV', 'column1 String, column2 UInt32') VALUES ('http interface', 42);
SELECT * FROM test_table;