Url Functions¶
This page lists all url functions available in Spark SQL.
parse_url¶
parse_url(url, partToExtract[, key]) - Extracts a part from a URL.
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
Since: 2.0.0
try_parse_url¶
try_parse_url(url, partToExtract[, key]) - This is a special version of parse_url that performs the same operation, but returns a NULL value instead of raising an error if the parsing cannot be performed.
Examples:
> SELECT try_parse_url('http://spark.apache.org/path?query=1', 'HOST');
spark.apache.org
> SELECT try_parse_url('http://spark.apache.org/path?query=1', 'QUERY');
query=1
> SELECT try_parse_url('inva lid://spark.apache.org/path?query=1', 'QUERY');
NULL
> SELECT try_parse_url('http://spark.apache.org/path?query=1', 'QUERY', 'query');
1
Since: 4.0.0
try_url_decode¶
try_url_decode(str) - This is a special version of url_decode that performs the same operation, but returns a NULL value instead of raising an error if the decoding cannot be performed.
Arguments:
- str - a string expression to decode
Examples:
> SELECT try_url_decode('https%3A%2F%2Fspark.apache.org');
https://spark.apache.org
Since: 4.0.0
url_decode¶
url_decode(str) - Decodes a str in 'application/x-www-form-urlencoded' format using a specific encoding scheme.
Arguments:
- str - a string expression to decode
Examples:
> SELECT url_decode('https%3A%2F%2Fspark.apache.org');
https://spark.apache.org
Since: 3.4.0
url_encode¶
url_encode(str) - Translates a string into 'application/x-www-form-urlencoded' format using a specific encoding scheme.
Arguments:
str - a string expression to be translated
Examples:
> SELECT url_encode('https://spark.apache.org');
https%3A%2F%2Fspark.apache.org
Since: 3.4.0