parse_url
function
Applies to: Databricks SQL Databricks Runtime
Extracts a part from url
.
Returns
A STRING.
partToExtract
must be one of:
'HOST'
'PATH'
'QUERY'
'REF'
'PROTOCOL'
'FILE'
'AUTHORITY'
'USERINFO'
key
is case-sensitive.
If a requested partToExtract
or key
is not found, NULL is returned.
Databricks returns an error if the url
string is invalid.
Note
In Databricks Runtime, if spark.sql.ansi.enabled is false
, parse_url
returns NULL
if the url
string is invalid.
Examples
> SELECT parse_url('http://spark.apache.org/path?query=1', 'HOST');
spark.apache.org
> SELECT parse_url('http://spark.apache.org/path?query=1', 'QUERY');
query=1
> SELECT parse_url('http://spark.apache.org/path?query=1', 'QUERY', 'query');
1
> SELECT parse_url('http://spark. apache.org/path?query=1', 'QUERY', 'query');
Error: Illegal argument