Tous les produits
Search
Centre de documentation

MaxCompute:NET_HOST

Dernière mise à jour :Sep 22, 2026

La fonction NET_HOST extrait le nom d'hôte d'une URL.

Syntaxe

STRING NET_HOST(STRING <url>)

Paramètres

url : Obligatoire. Chaîne d'URL à analyser. Ce paramètre doit être de type STRING.

Remarque

Pour des résultats optimaux, la chaîne d'URL doit respecter le format défini dans la RFC 3986.

Valeur renvoyée

Renvoie une valeur STRING correspondant au nom d'hôte extrait de l'URL.

  • Si l'URL inclut un numéro de port, celui-ci est conservé dans le résultat.

  • Si la fonction ne parvient pas à analyser l'URL d'entrée, elle renvoie NULL.

Fonctions d'analyse connexes

Pour analyser d'autres parties d'une URL, utilisez les fonctions suivantes :

  • NET_PUBLIC_SUFFIX : Extrait le suffixe public (tel que com, org ou net) d'une URL.

  • NET_REG_DOMAIN : Extrait le nom de domaine enregistré ou enregistrable d'une URL. Le nom de domaine enregistrable correspond au suffixe public précédé de son libellé immédiat.

Exemples

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          | 
+-----------------------------------+-------------------------------------------------------------------------------+-------------------+------------+---------------+

Fonctions connexes

NET_HOST est une fonction réseau. Pour plus d'informations sur les fonctions réseau, consultez la page Network Functions Overview.