すべてのプロダクト
Search
ドキュメントセンター

MaxCompute:PARSE_URL

最終更新日:Jan 17, 2025

urlを解析し、partで指定した値に基づいて情報を抽出します。

構文

string parse_url(string <url>, string <part>[, string <key>])

パラメーター

  • url: 必須です。 STRING型の値。 このパラメータはURLを指定します。 URLが無効な場合、エラーが返されます。

  • part: 必須です。 STRING型の値。 有効な値: HOST、PATH、QUERY、REF、PROTOCOL、AUTHORITY、FILE、USERINFO。 このパラメーターの値は大文字と小文字を区別しません。

  • key: オプション。 partがQUERYに設定されている場合、この関数はkeyに対応する値を返します。

戻り値

STRING型の値が返されます。 戻り値は、次のルールによって異なります。

  • urlpart、またはkeyの値がnullの場合、nullが返されます。

  • partの値が無効な場合、エラーが返されます。

-- The return value is example.com. 
select parse_url('file://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose', 'HOST');
-- The return value is /over/there/index.dtb. 
select parse_url('file://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose', 'PATH');
-- The return value is animal. 
select parse_url('file://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose', 'QUERY', 'type');
-- The return value is nose. 
select parse_url('file://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose', 'REF');
-- The return value is file. 
select parse_url('file://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose', 'PROTOCOL');
-- The return value is username:password@example.com:8042. 
select parse_url('file://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose', 'AUTHORITY');
-- The return value is username:password. 
select parse_url('file://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose', 'USERINFO');

関連関数

PARSE_URLは文字列関数です。 文字列検索と変換に関連する関数の詳細については、文字列関数.