Todos os produtos
Search
Central de documentação

MaxCompute:NET_HOST

Última atualização: Sep 22, 2026

A função NET_HOST extrai o nome do host de uma string de URL.

Sintaxe

STRING NET_HOST(STRING <url>)

Parâmetros

url: Obrigatório. A string de URL a ser analisada. Este parâmetro deve ser do tipo STRING.

Nota

Para obter os melhores resultados, a string de URL deve seguir o formato definido na RFC 3986.

Valor de retorno

Retorna um valor STRING que representa o nome do host extraído da URL.

  • Se a URL incluir um número de porta, o número da porta é mantido no resultado.

  • Se a função não conseguir analisar a URL de entrada, ela retorna NULL.

Funções de análise relacionadas

Para extrair outras partes de uma URL, use as seguintes funções:

  • NET_PUBLIC_SUFFIX: Extrai o sufixo público, como com, org ou net, de uma URL.

  • NET_REG_DOMAIN: Extrai o nome de domínio registrado ou registrável de uma URL. O nome de domínio registrável é o sufixo público mais o rótulo anterior.

Exemplos

SELECT input
,description
,NET_HOST(input) AS HOST
,NET_PUBLIC_SUFFIX(input) AS SUFFIX
,NET_REG_DOMAIN(input) AS DOMAIN  
FROM (
  SELECT "" AS input, "invalid input" AS description
  UNION ALL SELECT "http://abc.xyz", "standard URL"
  UNION ALL SELECT "//user:password@a.b:80/path?query",
                   "standard URL with relative scheme, port, path and query, but no public suffix"
  UNION ALL SELECT "https://[::1]:80", "standard URL with IPv6 host"
  UNION ALL SELECT "http://example.web.china", "standard URL with internationalized domain name"
  UNION ALL SELECT "    www.Example.Co.UK    ",
                   "non-standard URL with spaces, upper case letters, and without scheme"
  UNION ALL SELECT "mailto:?to=&subject=&body=", "URI rather than URL--unsupported"
);
                         
+-----------------------------------+-------------------------------------------------------------------------------+-------------------+------------+---------------+
| input                             | description                                                                   | host              | suffix     | domain        | 
+-----------------------------------+-------------------------------------------------------------------------------+-------------------+------------+---------------+
|                                   | invalid input                                                                 | NULL              | NULL       | NULL          | 
| http://abc.xyz                    | standard URL                                                                  | abc.xyz           | xyz        | abc.xyz       | 
| //user:password@a.b:80/path?query | standard URL with relative scheme, port, path and query, but no public suffix | a.b               | NULL       | NULL          | 
| https://[::1]:80                  | standard URL with IPv6 host                                                   | [::1]             | NULL       | NULL          | 
| http://example.web.china          | standard URL with internationalized domain name                               | example.web.china | china      | web.china     | 
|         www.Example.Co.UK         | non-standard URL with spaces, upper case letters, and without scheme          | www.Example.Co.UK | Co.UK      | Example.Co.UK | 
| mailto:?to=&subject=&body=        | URI rather than URL--unsupported                                              | mailto            | NULL       | NULL          | 
+-----------------------------------+-------------------------------------------------------------------------------+-------------------+------------+---------------+

Funções relacionadas

NET_HOST é uma função de rede. Para obter mais informações sobre funções de rede, consulte Visão geral das funções de rede.