>>> spark.sql("SELECT parse_url('https://example.com/a?x=1', 'QUERY', 'x') AS result, typeof(parse_url('https://example.com/a?x=1', 'QUERY', 'x')) AS type").show(truncate=False)
+------+------+
|result|type  |
+------+------+
|1     |string|
+------+------+

>>> spark.sql("SELECT parse_url('https://example.com/path#frag', 'REF') AS result, typeof(parse_url('https://example.com/path#frag', 'REF')) AS type").show(truncate=False)
+------+------+
|result|type  |
+------+------+
|frag  |string|
+------+------+

>>> spark.sql("SELECT parse_url('ftp://user:pwd@ftp.example.com:21/files', 'USERINFO') AS result, typeof(parse_url('ftp://user:pwd@ftp.example.com:21/files', 'USERINFO')) AS type").show(truncate=False)
+--------+------+
|result  |type  |
+--------+------+
|user:pwd|string|
+--------+------+

>>> spark.sql("SELECT parse_url('http://[2001:db8::2]:8080/index.html?ok=1', 'HOST') AS result, typeof(parse_url('http://[2001:db8::2]:8080/index.html?ok=1', 'HOST')) AS type").show(truncate=False)
+-------------+------+
|result       |type  |
+-------------+------+
|[2001:db8::2]|string|
+-------------+------+

>>> spark.sql("SELECT parse_url('https://example.com', 'PATH') AS result, typeof(parse_url('https://example.com', 'PATH')) AS type").show(truncate=False)
+------+------+
|result|type  |
+------+------+
|      |string|
+------+------+

>>> spark.sql("SELECT parse_url('https://example.com/a/b?x=1&y=2#frag', 'PROTOCOL') AS result, typeof(parse_url('https://example.com/a/b?x=1&y=2#frag', 'PROTOCOL')) AS type").show(truncate=False)
+------+------+
|result|type  |
+------+------+
|https |string|
+------+------+

>>> spark.sql("select parse_url('http://userinfo@spark.apache.org/path?query=1#Ref', 'HOST')").show(truncate=False)
+------------------------------------------------------------------+
|parse_url(http://userinfo@spark.apache.org/path?query=1#Ref, HOST)|
+------------------------------------------------------------------+
|spark.apache.org                                                  |
+------------------------------------------------------------------+

>>> spark.sql("select parse_url('http://userinfo@spark.apache.org/path?query=1#Ref', 'PATH')").show(truncate=False)
+------------------------------------------------------------------+
|parse_url(http://userinfo@spark.apache.org/path?query=1#Ref, PATH)|
+------------------------------------------------------------------+
|/path                                                             |
+------------------------------------------------------------------+

>>> spark.sql("select parse_url('http://userinfo@spark.apache.org/path?query=1#Ref', 'QUERY')").show(truncate=False)
+-------------------------------------------------------------------+
|parse_url(http://userinfo@spark.apache.org/path?query=1#Ref, QUERY)|
+-------------------------------------------------------------------+
|query=1                                                            |
+-------------------------------------------------------------------+

>>> spark.sql("select parse_url('http://userinfo@spark.apache.org/path?query=1#Ref', 'REF')").show(truncate=False)
+-----------------------------------------------------------------+
|parse_url(http://userinfo@spark.apache.org/path?query=1#Ref, REF)|
+-----------------------------------------------------------------+
|Ref                                                              |
+-----------------------------------------------------------------+

>>> spark.sql("select parse_url('http://userinfo@spark.apache.org/path?query=1#Ref', 'PROTOCOL')").show(truncate=False)
+----------------------------------------------------------------------+
|parse_url(http://userinfo@spark.apache.org/path?query=1#Ref, PROTOCOL)|
+----------------------------------------------------------------------+
|http                                                                  |
+----------------------------------------------------------------------+

>>> spark.sql("select parse_url('http://userinfo@spark.apache.org/path?query=1#Ref', 'FILE')").show(truncate=False)
+------------------------------------------------------------------+
|parse_url(http://userinfo@spark.apache.org/path?query=1#Ref, FILE)|
+------------------------------------------------------------------+
|/path?query=1                                                     |
+------------------------------------------------------------------+

>>> spark.sql("select parse_url('http://userinfo@spark.apache.org/path?query=1#Ref', 'AUTHORITY')").show(truncate=False)
+-----------------------------------------------------------------------+
|parse_url(http://userinfo@spark.apache.org/path?query=1#Ref, AUTHORITY)|
+-----------------------------------------------------------------------+
|userinfo@spark.apache.org                                              |
+-----------------------------------------------------------------------+

>>> spark.sql("select parse_url('http://userinfo@spark.apache.org/path?query=1#Ref', 'USERINFO')").show(truncate=False)
+----------------------------------------------------------------------+
|parse_url(http://userinfo@spark.apache.org/path?query=1#Ref, USERINFO)|
+----------------------------------------------------------------------+
|userinfo                                                              |
+----------------------------------------------------------------------+

