UrlPart
The UrlPart function extracts a specified component from a URL and returns it as text.
Syntax
Function arguments:
Notes
- For the purposes of the UrlPart function, a standard URL is constructed like the following:
scheme://userinfo@host:port/path?query#fragment.- The
authoritycomponent is a combination ofuserinfo,host, andport.
- The
- 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")returnsnullin Snowflake, but other dialects returndef.
- Snowflake does not return the leading
/for the path.UrlPart("path", "https://example.com/path/to/page")returnspath/to/pagerather than/path/to/page.
- Databricks and Trino don’t recognize paths that start after the first colon.
- Typically, in the
mailto:URI scheme, such asmailto:user@example.com,user@example.comwould be the path. ButUrlPart("path", mailto:user@example.com)returnsnullin Databricks and an empty string in Trino.
- Typically, in the
- Snowflake returns
nullfor URLs containing an IPv6 address.
- Results for invalid URLs vary by component and dialect.
Examples
Extracts the scheme from https://www.example.com and returns https.
Extracts the authority from https://user@www.example.com:1234/path/to/page and returns user@www.example.com:1234.
Extracts the query from https://www.example.com/path/to/page?query=string#fragment and returns query=string.
Extracts the fragment from https://www.example.com/path/to/page?query=string#sub-heading and returns sub-heading.

