> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Creates a table from the `URL` with given `format` and `structure`

# url

export const CloudNotSupportedBadge = () => {
  return <div className="cloudNotSupportedBadge">
            <div className="cloudNotSupportedIcon">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path strokeWidth="1.5" d="M6.33366 12.6666L12.3739 12.6667C13.6593 12.6667 14.7073 11.6187 14.7073 10.3334C14.7073 9.04804 13.6593 8.00003 12.3739 8.00003C12.3739 8.00003 12.3337 7.66659 12.0003 7.33325M10.667 5.33322C8.00033 2.33325 4.45395 4.78537 4.14195 6.68203C2.55728 6.7627 1.29395 8.06203 1.29395 9.6667C1.29395 11.3234 2.66699 12.6666 4.00033 12.6666" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.5" d="M2.66699 14L12.0003 4.66663" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
            </svg>

        </div>
            Not supported in ClickHouse Cloud
        </div>;
};

export const ExperimentalBadge = () => {
  return <div className="experimentalBadge">
            <div className="experimentalIcon">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path strokeWidth="1.25" d="M5.5 2H10.5" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.25" d="M9.50015 2V6.19625L13.4283 12.7425C13.4738 12.8183 13.4985 12.9049 13.4996 12.9934C13.5008 13.0818 13.4785 13.169 13.435 13.246C13.3914 13.323 13.3283 13.3871 13.2519 13.4317C13.1755 13.4764 13.0886 13.4999 13.0002 13.5H3.00015C2.91164 13.5 2.8247 13.4766 2.74822 13.432C2.67174 13.3874 2.60847 13.3233 2.56487 13.2463C2.52126 13.1693 2.49889 13.082 2.50004 12.9935C2.50119 12.905 2.52582 12.8184 2.5714 12.7425L6.50015 6.19625V2" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.25" d="M4.47656 9.56754C5.30344 9.41254 6.47656 9.47942 7.99969 10.25C10.0153 11.2707 11.4216 11.0569 12.2184 10.7282" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
        </div>
            Experimental feature. <u><a href="/docs/beta-and-experimental-features#experimental-features">Learn more.</a></u>
        </div>;
};

# url Table Function

`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](/reference/engines/table-engines/special/url) tables.

<h2 id="syntax">
  Syntax
</h2>

```sql theme={null}
url(URL [,format] [,structure] [,headers])
```

<h2 id="parameters">
  Parameters
</h2>

| Parameter   | Description                                                                                                                                                                             |
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `URL`       | Single quoted HTTP or HTTPS server address, which can accept `GET` or `POST` requests (for `SELECT` or `INSERT` queries correspondingly). Type: [String](/reference/data-types/string). |
| `format`    | [Format](/reference/formats/index) of the data. Type: [String](/reference/data-types/string).                                                                                           |
| `structure` | Table structure in `'UserID UInt64, Name String'` format. Determines column names and types. Type: [String](/reference/data-types/string).                                              |
| `headers`   | Headers in `'headers('key1'='value1', 'key2'='value2')'` format. You can set headers for HTTP call.                                                                                     |

<h2 id="returned_value">
  Returned value
</h2>

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

<h2 id="examples">
  Examples
</h2>

Getting the first 3 lines of a table that contains columns of `String` and [UInt32](/reference/data-types/int-uint) type from HTTP-server which answers in [CSV](/reference/formats/CSV/CSV) format.

```sql theme={null}
SELECT * FROM url('http://127.0.0.1:12345/', CSV, 'column1 String, column2 UInt32', headers('Accept'='text/csv; charset=utf-8')) LIMIT 3;
```

Inserting data from a `URL` into a table:

```sql theme={null}
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;
```

<h2 id="globs-in-url">
  Globs in URL
</h2>

Patterns in `{ }` 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](/reference/functions/table-functions/remote#globs-in-addresses) function.
Character `|` inside patterns is used to specify failover addresses. They are iterated in the same order as listed in the pattern. The number of generated addresses is limited by [glob\_expansion\_max\_elements](/reference/settings/session-settings#glob_expansion_max_elements) setting.

<h2 id="virtual-columns">
  Virtual Columns
</h2>

* `_path` — Path to the `URL`. Type: `LowCardinality(String)`.
* `_file` — Resource name of the `URL`. Type: `LowCardinality(String)`.
* `_size` — Size of the resource in bytes. Type: `Nullable(UInt64)`. If the size is unknown, the value is `NULL`.
* `_time` — Last modified time of the file. Type: `Nullable(DateTime)`. If the time is unknown, the value is `NULL`.
* `_headers` - HTTP response headers. Type: `Map(LowCardinality(String), LowCardinality(String))`.

<h2 id="hive-style-partitioning">
  use\_hive\_partitioning setting
</h2>

When setting `use_hive_partitioning` is set to 1, ClickHouse will detect Hive-style partitioning in the path (`/name=value/`) and will allow to use partition columns as virtual columns in the query. These virtual columns will have the same names as in the partitioned path.

**Example**

Use virtual column, created with Hive-style partitioning

```sql theme={null}
SELECT * FROM url('http://data/path/date=*/country=*/code=*/*.parquet') WHERE date > '2020-01-01' AND country = 'Netherlands' AND code = 42;
```

<h2 id="resolving-relative-urls">
  Resolving relative URLs
</h2>

The [url\_base](/reference/settings/session-settings#url_base) setting allows passing a relative URL to the `url` function. When `url_base` is set and the function argument is a relative reference, it is resolved against the base URL per [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986).

The resolution rules are:

* **Path-relative** (e.g. `data.csv`): merged with the base URL path — everything after the last `/` of the base path is replaced. The trailing slash matters: `https://example.com/dir/` + `data.csv` gives `https://example.com/dir/data.csv`, but `https://example.com/dir` + `data.csv` gives `https://example.com/data.csv`. Dot segments (`./` and `../`) are normalized.
* **Host-relative** (e.g. `/test/data.csv`): resolved using the scheme and host of the base URL.
* **Scheme-relative** (e.g. `//other.com/test/data.csv`): resolved using the scheme of the base URL.
* **Query-only** (e.g. `?x=1`): appended to the full base path, replacing any existing query or fragment.
* **Fragment-only** (e.g. `#frag`): appended to the base URL, preserving the query, replacing any existing fragment.
* **Empty**: returns the base URL without fragment.
* **Absolute URL**: passed through unchanged; `url_base` is ignored.

**Example**

```sql theme={null}
SET url_base = 'https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/';
SELECT * FROM url('tests/queries/0_stateless/data_csv/data.csv', CSV) LIMIT 3;
```

<h2 id="storage-settings">
  Storage Settings
</h2>

* [engine\_url\_skip\_empty\_files](/reference/settings/session-settings#engine_url_skip_empty_files) - allows to skip empty files while reading. Disabled by default.
* [enable\_url\_encoding](/reference/settings/session-settings#enable_url_encoding) - allows to enable/disable decoding/encoding path in uri. Enabled by default.
* [url\_base](/reference/settings/session-settings#url_base) - base URL for resolving relative URLs passed to the `url` function.

<h2 id="permissions">
  Permissions
</h2>

`url` function requires `CREATE TEMPORARY TABLE` permission. As such - it'll not work for users with [readonly](/concepts/features/configuration/settings/permissions-for-queries#readonly) = 1 setting. At least readonly = 2 is required.

<h2 id="related">
  Related
</h2>

* [Virtual columns](/reference/engines/table-engines/index#table_engines-virtual_columns)
