Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Solutions
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Managed Service for ClickHouse
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Information about existing clusters
    • Creating clusters
    • Connecting to databases
    • Stop and start the cluster
    • SQL queries in the management console
    • Changing cluster and database settings
    • Connecting to DataLens
    • Connecting external dictionaries
    • Adding your own geobase
    • Enabling machine learning models
    • Changing ClickHouse versions
    • Managing ClickHouse hosts
    • Adding ZooKeeper hosts
    • Database management
    • Managing database users
    • Managing backups
    • How to manage shards
    • Deleting clusters
  • Solutions
    • Adding data to the database
    • Sharding tables
  • Concepts
    • Relationship between service resources
    • Host classes
    • Network in Yandex Managed Service for ClickHouse
    • Quotas and limits
    • Storage types
    • Backups
    • Replication
    • Dictionaries
    • Sharding
    • Supported clients
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Before January 1, 2019
      • From January 1 to March 1, 2019
      • From March 1, 2019 to February 1, 2020
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • BackupService
      • ClusterService
      • DatabaseService
      • FormatSchemaService
      • MlModelService
      • ResourcePresetService
      • UserService
      • VersionsService
      • OperationService
    • REST
      • Overview
      • Backup
        • Overview
        • get
        • list
      • Cluster
        • Overview
        • addHosts
        • addShard
        • addZookeeper
        • backup
        • create
        • createExternalDictionary
        • createShardGroup
        • delete
        • deleteExternalDictionary
        • deleteHosts
        • deleteShard
        • deleteShardGroup
        • get
        • getShard
        • getShardGroup
        • list
        • listBackups
        • listHosts
        • listLogs
        • listOperations
        • listShardGroups
        • listShards
        • move
        • rescheduleMaintenance
        • restore
        • start
        • stop
        • streamLogs
        • update
        • updateShard
        • updateShardGroup
      • Database
        • Overview
        • create
        • delete
        • get
        • list
      • FormatSchema
        • Overview
        • create
        • delete
        • get
        • list
        • update
      • MlModel
        • Overview
        • create
        • delete
        • get
        • list
        • update
      • ResourcePreset
        • Overview
        • get
        • list
      • User
        • Overview
        • create
        • delete
        • get
        • grantPermission
        • list
        • revokePermission
        • update
      • Versions
        • Overview
        • list
      • Operation
        • Overview
        • get
  • Questions and answers
    • General questions
    • Questions about ClickHouse
    • All questions on the same page
  1. Step-by-step instructions
  2. Adding your own geobase

Adding your own geobase

  • Create a geobase
  • Upload your geobase to Yandex.Cloud
  • Add the geobase

Managed Service for ClickHouse contains a built-in geobase dictionary and a set of functions for working with it. The built-in dictionary lets you:

  • Get the name of a region in the required language by its ID.
  • Get the ID of a city, region, federal district, country, and continent by the region ID.
  • Check whether one region is part of another.
  • Get a chain of parent regions.

Learn more about geobase functions in the ClickHouse documentation.

If you're not satisfied with the built-in geobase, you can add your own to ClickHouse clusters:

  1. Create a geobase.
  2. Upload the geobase to Yandex.Cloud.
  3. Add the geobase to the ClickHouse cluster.

Create a geobase

Geobases in ClickHouse are text files containing the hierarchy and names of regions. You can add several alternative geobases to ClickHouse to reflect alternative viewpoints on the regional structure of different countries. Learn more in the ClickHouse documentation.

To create a geobase:

  1. Create a regions_hierarchy.txt file with a hierarchy of regions. The file must be in TSV tabular format without headers and with the following columns:

    • Region ID (UInt32).
    • Parent region ID (UInt32).
    • Region type (UInt8): 1 - continent, 3 - country, 4 - federal district, 5 - area, 6 - city. There are no values for other types.
    • Population (UInt32): Optional.
  2. To add an alternative hierarchy of regions, create regions_hierarchy_<suffix>.txt files with the same structure. To use an alternative geobase, pass this suffix when calling the function. For example:

    regionToCountry(RegionID) — Uses the default dictionary: regions_hierarchy.txt.
    regionToCountry(RegionID, 'ua') — Uses the dictionary with the ua suffix: regions_hierarchy_ua.txt.
    
  3. Create the file regions_names.txt with the region names. The file must be in TSV tabular format without headers and with the following columns:

    • Region ID (UInt32).
    • region name (String) — Can't contain tabs or newlines, even escaped ones.
  4. To add region names in other languages to your geobase, create regions_names_<language code>.txt files with the same structure. For example, you may create regions_names_en.txt for English and regions_names_tr.txt for Turkish.

  5. Package your geobase files as TAR, TAR.GZ, or ZIP archives.

Upload your geobase to Yandex.Cloud

Managed Service for ClickHouse only works with publicly readable geobases that are uploaded to Object Storage:

  1. Upload archive with a geobase in Object Storage.

  2. Set up public read access to the geobase file.

  3. Get a public link to the geobase.

Add the geobase

Management console
  1. Go to the folder page and select Managed Service for ClickHouse.
  2. Select the cluster and click Edit cluster in the top panel.
  3. Under DBMS settings, click Configure.
  4. In the Geobase uri field, provide a public link to the geobase archive in Object Storage.
In this article:
  • Create a geobase
  • Upload your geobase to Yandex.Cloud
  • Add the geobase
Language / Region
Careers
Privacy policy
Terms of use
Brandbook
© 2021 Yandex.Cloud LLC