我正在寻找一个与Hive的parse_url(......,'HOST')相当的Postgres(实际上是Redshift ).
Postgres docs say it has a URL parser as part of its full text search. This blog post has a regex which may or may not be bulletproof. What is best?
在Redshift开始支持PostgreSQL的正则表达式函数之前,如果你想让主机脱离Redshift SQL中的HTTP/S URL,你必须做类似的事情:
select split_part(url, '/', 3) as host from my_table
Run Code Online (Sandbox Code Playgroud)
Redshift现在有一个REGEXP_SUBSTR函数:
它在字符串中搜索正则表达式并返回匹配的第一个子字符串.提取主机的正则表达式的一个示例:
select REGEXP_SUBSTR(url, '[^/]+\\.[^/:]+') from my_table;
Run Code Online (Sandbox Code Playgroud)