> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# UrlPart

> Use the Sigma UrlPart function to extract a specified component from a URL and return it as text.

The **UrlPart** function extracts a specified component from a URL and returns it as text.

## Syntax

```
UrlPart(component, url)
```

Function arguments:

|               |                                                                                                                                        |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| **component** | The part of the URL to be extracted. Can be one of  “scheme”, “authority”, “userinfo”, “host”, “port”, “path”, “query”, or “fragment”. |
| **url**       | The URL to extract the component from. If `url` is null the function returns `null`.                                                   |

## Notes

* For the purposes of the **UrlPart** function, a standard URL is constructed like the following: `scheme://userinfo@host:port/path?query#fragment`.
  * The `authority` component is a combination of `userinfo`, `host`, and `port`.
* Though all platforms are supported, Sigma uses native URL parsing for all SQL dialects where possible. As a result, there are behavior differences between platforms, including:
  * Results for invalid URLs vary by component and dialect.
    * `UrlPart("query", "abc?def")` returns `null` in Snowflake, but other dialects return `def`.
  * Snowflake does not return the leading `/` for the path.
    * `UrlPart("path", "https://example.com/path/to/page")` returns `path/to/page` rather than `/path/to/page`.
  * Databricks and Trino don't recognize paths that start after the first colon.
    * Typically, in the `mailto:` URI scheme, such as `mailto:user@example.com`, `user@example.com` would be the path. But `UrlPart("path", mailto:user@example.com)` returns `null` in Databricks and an empty string in Trino.
  * Snowflake returns `null` for URLs containing an IPv6 address.

## Examples

```
UrlPart("scheme", "https://www.example.com")
```

Extracts the scheme from `https://www.example.com` and returns `https`.

```
UrlPart("authority", "https://user@www.example.com:1234/path/to/page")
```

Extracts the authority from `https://user@www.example.com:1234/path/to/page` and returns `user@www.example.com:1234`.

```
UrlPart("query", "https://www.example.com/path/to/page?query=string#fragment")
```

Extracts the query from `https://www.example.com/path/to/page?query=string#fragment` and returns `query=string`.

```
UrlPart("fragment", "https://www.example.com/path/to/page?query=string#sub-heading")
```

Extracts the fragment from `https://www.example.com/path/to/page?query=string#sub-heading` and returns `sub-heading`.