ClickHouse/docs/fr/sql-reference/functions/ym-dict-functions.md
Ivan Blinkov cd14f9ebcb
SQL reference refactoring (#10857)
* split up select.md

* array-join.md basic refactoring

* distinct.md basic refactoring

* format.md basic refactoring

* from.md basic refactoring

* group-by.md basic refactoring

* having.md basic refactoring

* additional index.md refactoring

* into-outfile.md basic refactoring

* join.md basic refactoring

* limit.md basic refactoring

* limit-by.md basic refactoring

* order-by.md basic refactoring

* prewhere.md basic refactoring

* adjust operators/index.md links

* adjust sample.md links

* adjust more links

* adjust operatots links

* fix some links

* adjust aggregate function article titles

* basic refactor of remaining select clauses

* absolute paths in make_links.sh

* run make_links.sh

* remove old select.md locations

* translate docs/es

* translate docs/fr

* translate docs/fa

* remove old operators.md location

* change operators.md links

* adjust links in docs/es

* adjust links in docs/es

* minor texts adjustments

* wip

* update machine translations to use new links

* fix changelog

* es build fixes

* get rid of some select.md links

* temporary adjust ru links

* temporary adjust more ru links

* improve curly brace handling

* adjust ru as well

* fa build fix

* ru link fixes

* zh link fixes

* temporary disable part of anchor checks
2020-05-15 07:34:54 +03:00

8.3 KiB
Raw Blame History

machine_translated machine_translated_rev toc_priority toc_title
true 72537a2d52 59 Travailler avec Yandex.Dictionnaires Metrica

Fonctions pour travailler avec Yandex.Dictionnaires Metrica

Pour que les fonctions ci-dessous fonctionnent, la configuration du serveur doit spécifier les chemins et les adresses pour obtenir tous les Yandex.Dictionnaires Metrica. Les dictionnaires sont chargés au premier appel de l'une de ces fonctions. Si les listes de référence ne peuvent pas être chargées, une exception est levée.

Pour plus d'informations sur la création de listes de références, consultez la section “Dictionaries”.

Plusieurs Geobases

ClickHouse soutient le travail avec plusieurs géobases alternatives (hiérarchies régionales) simultanément, afin de soutenir diverses perspectives sur les pays auxquels appartiennent certaines régions.

Le clickhouse-server config spécifie le fichier avec l'échelon régional::<path_to_regions_hierarchy_file>/opt/geo/regions_hierarchy.txt</path_to_regions_hierarchy_file>

Outre ce fichier, il recherche également les fichiers à proximité qui ont le symbole _ et tout suffixe ajouté au nom (avant l'extension de fichier). Par exemple, il trouvera également le fichier /opt/geo/regions_hierarchy_ua.txt si présente.

ua est appelée la clé du dictionnaire. Pour un dictionnaire sans suffixe, la clé est une chaîne vide.

Tous les dictionnaires sont rechargés dans l'exécution (une fois toutes les secondes, comme défini dans le paramètre de configuration builtin_dictionaries_reload_interval, ou une fois par heure par défaut). Cependant, la liste des dictionnaires disponibles est définie une fois, lorsque le serveur démarre.

All functions for working with regions have an optional argument at the end the dictionary key. It is referred to as the geobase. Exemple:

regionToCountry(RegionID)  Uses the default dictionary: /opt/geo/regions_hierarchy.txt
regionToCountry(RegionID, '')  Uses the default dictionary: /opt/geo/regions_hierarchy.txt
regionToCountry(RegionID, 'ua')  Uses the dictionary for the 'ua' key: /opt/geo/regions_hierarchy_ua.txt

regionToCity (id [, geobase])

Accepts a UInt32 number the region ID from the Yandex geobase. If this region is a city or part of a city, it returns the region ID for the appropriate city. Otherwise, returns 0.

regionToArea (id [, geobase])

Convertit une région en une zone (tapez 5 dans la géobase). Dans tous les autres cas, cette fonction est la même que regionToCity.

SELECT DISTINCT regionToName(regionToArea(toUInt32(number), 'ua'))
FROM system.numbers
LIMIT 15
┌─regionToName(regionToArea(toUInt32(number), \'ua\'))─┐
│                                                      │
│ Moscow and Moscow region                             │
│ St. Petersburg and Leningrad region                  │
│ Belgorod region                                      │
│ Ivanovsk region                                      │
│ Kaluga region                                        │
│ Kostroma region                                      │
│ Kursk region                                         │
│ Lipetsk region                                       │
│ Orlov region                                         │
│ Ryazan region                                        │
│ Smolensk region                                      │
│ Tambov region                                        │
│ Tver region                                          │
│ Tula region                                          │
└──────────────────────────────────────────────────────┘

regionToDistrict(id [, geobase])

Convertit une région en district fédéral (type 4 dans la géobase). Dans tous les autres cas, cette fonction est la même que regionToCity.

SELECT DISTINCT regionToName(regionToDistrict(toUInt32(number), 'ua'))
FROM system.numbers
LIMIT 15
┌─regionToName(regionToDistrict(toUInt32(number), \'ua\'))─┐
│                                                          │
│ Central federal district                                 │
│ Northwest federal district                               │
│ South federal district                                   │
│ North Caucases federal district                          │
│ Privolga federal district                                │
│ Ural federal district                                    │
│ Siberian federal district                                │
│ Far East federal district                                │
│ Scotland                                                 │
│ Faroe Islands                                            │
│ Flemish region                                           │
│ Brussels capital region                                  │
│ Wallonia                                                 │
│ Federation of Bosnia and Herzegovina                     │
└──────────────────────────────────────────────────────────┘

regionToCountry (id [, geobase])

Convertit une région en un pays. Dans tous les autres cas, cette fonction est la même que regionToCity. Exemple: regionToCountry(toUInt32(213)) = 225 convertit Moscou (213) en Russie (225).

regionToContinent(id [, géobase])

Convertit une région en continent. Dans tous les autres cas, cette fonction est la même que regionToCity. Exemple: regionToContinent(toUInt32(213)) = 10001 convertit Moscou (213) en Eurasie (10001).

regionToTopContinent (#regiontotopcontinent)

Trouve le continent le plus élevé dans la hiérarchie de la région.

Syntaxe

regionToTopContinent(id[, geobase]);

Paramètre

Valeur renvoyée

  • Identifiant du continent de haut niveau (ce dernier lorsque vous grimpez dans la hiérarchie des régions).
  • 0, si il n'y a aucun.

Type: UInt32.

regionToPopulation (id [, geobase])

Obtient la population d'une région. La population peut être enregistrée dans des fichiers avec la géobase. Voir la section “External dictionaries”. Si la population n'est pas enregistrée pour la région, elle renvoie 0. Dans la géobase Yandex, la population peut être enregistrée pour les régions enfants, mais pas pour les régions parentes.

regionIn(lhs, rhs [, géobase])

Vérifie si un lhs région appartient à une rhs région. Renvoie un nombre UInt8 égal à 1 s'il appartient, Ou 0 s'il n'appartient pas. The relationship is reflexive any region also belongs to itself.

regionHierarchy (id [, geobase])

Accepts a UInt32 number the region ID from the Yandex geobase. Returns an array of region IDs consisting of the passed region and all parents along the chain. Exemple: regionHierarchy(toUInt32(213)) = [213,1,3,225,10001,10000].

regionToName(id [, lang])

Accepts a UInt32 number the region ID from the Yandex geobase. A string with the name of the language can be passed as a second argument. Supported languages are: ru, en, ua, uk, by, kz, tr. If the second argument is omitted, the language ru is used. If the language is not supported, an exception is thrown. Returns a string the name of the region in the corresponding language. If the region with the specified ID doesn't exist, an empty string is returned.

ua et uk les deux signifient ukrainien.

Article Original