Todos os produtos
Search
Central de documentação

MaxCompute:NET_HOST

Última atualização: Jun 26, 2026

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

Formato do comando

STRING NET_HOST(STRING <url>)

Descrição dos parâmetros

url: Obrigatório. Tipo STRING. String URL a analisar.

Nota

Para obter os melhores resultados de análise, a string URL deve seguir o formato definido pela RFC 3986.

Valor de retorno

Retorna um valor do tipo STRING. A função analisa a URL fornecida e devolve a parte correspondente ao nome do host.

  • Se a URL incluir um número de porta, ele também será mantido no resultado.

  • Caso a função não consiga analisar a URL de entrada, retornará NULL.

Funções de análise relacionadas

Para extrair outras partes da URL além do nome do host, utilize as seguintes funções:

  • NET_PUBLIC_SUFFIX: Extrai o sufixo público da URL fornecida (como com, org ou net).

  • NET_REG_DOMAIN: Obtém o domínio registrado ou registrável da URL informada (ou seja, o sufixo público mais o rótulo imediatamente anterior).

Exemplos de uso

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://例子.卷筒纸.中国", "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://例子.卷筒纸.中国             | standard URL with internationalized domain name                               | 例子.卷筒纸.中国     | 中国       | 卷筒纸.中国     | 
|         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

A função NET_HOST faz parte do conjunto de funções de rede. Para consultar outras funções relacionadas a redes, consulte Funções de rede.