> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PARSE_URL

> Extracts a component or query parameter from a URL string.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

NULL url/part returns NULL. An explicitly supplied NULL key returns NULL even for a part other than QUERY. Missing components or keys return NULL.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
parse_url(url, part [, key])
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| url | STRING | Yes | URL or relative URI. |
| part | STRING | Yes | Requested component. HOST, PATH, QUERY, REF, PROTOCOL, FILE, AUTHORITY or USERINFO (case-sensitive uppercase). |
| key | STRING | No | Query parameter name, used only with QUERY. Default: Return the full QUERY component when part is QUERY. |

## Returns

* Type: STRING
* Possible values: The requested component text, or NULL when absent or the part selector is unsupported.
* NULL behavior: NULL url/part returns NULL. An explicitly supplied NULL key returns NULL even for a part other than QUERY. Missing components or keys return NULL.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* Query extraction splits raw key=value pairs on & and returns the first matching key. It does not percent-decode values or convert plus to space; a key-only item without = does not match.
* A URL without an explicit scheme is parsed as a relative URI: PATH/QUERY/REF/FILE can exist, while HOST/PROTOCOL/AUTHORITY/USERINFO return NULL. An absolute URL with no explicit slash has an empty PATH rather than /.

## Examples

### Example values

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT parse_url('https://example.com/p?a=1&b=2', 'HOST') AS host, parse_url('https://example.com/p?a=1&b=2', 'QUERY', 'a') AS parameter;
```

| host | parameter |
| - | - |
| example.com | 1 |

### Read a path and a missing query key

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT parse_url('https://example.com/docs?q=sql', 'PATH') AS path, parse_url('https://example.com/docs?q=sql', 'QUERY', 'missing') AS missing_key;
```

| path | missing\_key |
| - | - |
| /docs | NULL |

## Limitations

* Malformed absolute URLs can raise a parsing error. Unsupported part names return NULL. URLs are normalized during parsing; raw query and path components keep percent-encoded characters.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.