Skip to main content

UpdateExternalDictionary

Updates an external dictionary for the specified ClickHouse cluster.

import {
cloudApi,
decodeMessage,
serviceClients,
Session,
waitForOperation,
} from "@yandex-cloud/nodejs-sdk";

const Cluster = cloudApi.dataproc.cluster.Cluster;
const Layout_Type = cloudApi.mdb.clickhouse_config_clickhouse.Layout_Type;
const PostgresqlSource_SslMode =
cloudApi.mdb.clickhouse_config_clickhouse.PostgresqlSource_SslMode;
const UpdateClusterExternalDictionaryRequest =
cloudApi.mdb.clickhouse_cluster_service
.UpdateClusterExternalDictionaryRequest;

(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.ClusterServiceClient);

const operation = await client.updateExternalDictionary(
UpdateClusterExternalDictionaryRequest.fromPartial({
clusterId: "clusterId",
// externalDictionary: {
// name: "name",
// structure: {
// id: {
// name: "name"
// },
// key: {
// attributes: [{
// name: "name",
// type: "type",
// nullValue: "nullValue",
// expression: "expression",
// hierarchical: true,
// injective: true
// }]
// },
// rangeMin: {
// name: "name",
// type: "type",
// nullValue: "nullValue",
// expression: "expression",
// hierarchical: true,
// injective: true
// },
// rangeMax: {
// name: "name",
// type: "type",
// nullValue: "nullValue",
// expression: "expression",
// hierarchical: true,
// injective: true
// },
// attributes: [{
// name: "name",
// type: "type",
// nullValue: "nullValue",
// expression: "expression",
// hierarchical: true,
// injective: true
// }]
// },
// layout: {
// type: Layout_Type.FLAT,
// sizeInCells: 0,
// maxArraySize: 0
// },
// fixedLifetime: 0,
// lifetimeRange: {
// min: 0,
// max: 0
// },
// httpSource: {
// url: "url",
// format: "format",
// headers: [{
// name: "name",
// value: "value"
// }]
// },
// mysqlSource: {
// db: "db",
// table: "table",
// port: 0,
// user: "user",
// password: "password",
// replicas: [{
// host: "host",
// priority: 0,
// port: 0,
// user: "user",
// password: "password"
// }],
// where: "where",
// invalidateQuery: "invalidateQuery",
// closeConnection: {
// value: true
// },
// shareConnection: {
// value: true
// }
// },
// clickhouseSource: {
// db: "db",
// table: "table",
// host: "host",
// port: 0,
// user: "user",
// password: "password",
// where: "where",
// secure: {
// value: true
// }
// },
// mongodbSource: {
// db: "db",
// collection: "collection",
// host: "host",
// port: 0,
// user: "user",
// password: "password",
// options: "options"
// },
// postgresqlSource: {
// db: "db",
// table: "table",
// hosts: ["hosts"],
// port: 0,
// user: "user",
// password: "password",
// invalidateQuery: "invalidateQuery",
// sslMode: PostgresqlSource_SslMode.DISABLE
// }
// },
// updateMask: {
// paths: ["paths"]
// }
})
);
const finishedOp = await waitForOperation(operation, session);

if (finishedOp.response) {
const result = decodeMessage<typeof Cluster>(finishedOp.response);
console.log(result);
}
})();

UpdateClusterExternalDictionaryRequest

clusterId : string

ID of the ClickHouse cluster to update the external dictionary for. To get the cluster ID, use a List request.

externalDictionary : config.ClickhouseConfig.ExternalDictionary

Configuration of the external dictionary.

updateMask : google.protobuf.FieldMask

Field mask that specifies which fields of the External Dictionary should be updated.

ExternalDictionary

HttpSource
Header
name : string
value : string
url : string

URL of the source dictionary available over HTTP.

format : string

The data format. Valid values are all formats supported by ClickHouse SQL dialect.

headers : Header

HTTP headers.

MysqlSource
Replica
host : string

MySQL host of the replica.

priority : int64

The priority of the replica that ClickHouse takes into account when connecting. Replica with the highest priority should have this field set to the lowest number.

port : int64

Port to use when connecting to the replica. If a port is not specified for a replica, ClickHouse uses the port specified for the source.

user : string

Name of the MySQL database user.

password : string

Password of the MySQL database user.

db : string

Name of the MySQL database to connect to.

table : string

Name of the database table to use as a ClickHouse dictionary.

port : int64

Default port to use when connecting to a replica of the dictionary source.

user : string

Name of the default user for replicas of the dictionary source.

password : string

Password of the default user for replicas of the dictionary source.

replicas : Replica

List of MySQL replicas of the database used as dictionary source.

where : string

Selection criteria for the data in the specified MySQL table.

invalidateQuery : string

Query for checking the dictionary status, to pull only updated data. For more details, see ClickHouse documentation on dictionaries.

closeConnection : google.protobuf.BoolValue

Should the connection be closed after each request.

shareConnection : google.protobuf.BoolValue

Should a connection be shared for some requests.

ClickhouseSource
db : string

Name of the ClickHouse database.

table : string

Name of the table in the specified database to be used as the dictionary source.

host : string

ClickHouse host of the specified database.

port : int64

Port to use when connecting to the host.

user : string

Name of the ClickHouse database user.

password : string

Password of the ClickHouse database user.

where : string

Selection criteria for the data in the specified ClickHouse table.

secure : google.protobuf.BoolValue

Use ssl for connection.

MongodbSource
db : string

Name of the MongoDB database.

collection : string

Name of the collection in the specified database to be used as the dictionary source.

host : string

MongoDB host of the specified database.

port : int64

Port to use when connecting to the host.

user : string

Name of the MongoDB database user.

password : string

Password of the MongoDB database user.

options : string
PostgresqlSource
SslMode
  • SSL_MODE_UNSPECIFIED

  • DISABLE

    Only try a non-SSL connection.

  • ALLOW

    First try a non-SSL connection; if that fails, try an SSL connection.

  • PREFER

    First try an SSL connection; if that fails, try a non-SSL connection.

  • VERIFY_CA

    Only try an SSL connection, and verify that the server certificate is issued by a trusted certificate authority (CA).

  • VERIFY_FULL

    Only try an SSL connection, verify that the server certificate is issued by a trusted CA and that the requested server host name matches that in the certificate.

db : string

Name of the PostrgreSQL database.

table : string

Name of the table in the specified database to be used as the dictionary source.

hosts : string

Name of the PostrgreSQL host

port : int64

Port to use when connecting to the host.

user : string

Name of the PostrgreSQL database user.

password : string

Password of the PostrgreSQL database user.

invalidateQuery : string

Query for checking the dictionary status, to pull only updated data. For more details, see ClickHouse documentation on dictionaries.

sslMode : SslMode

Mode of SSL TCP/IP connection to the PostgreSQL host. For more details, see PostgreSQL documentation.

Structure
Attribute
name : string

Name of the column.

type : string

Type of the column.

nullValue : string

Default value for an element without data (for example, an empty string).

expression : string

Expression, describing the attribute, if applicable.

hierarchical : bool

Indication of hierarchy support. Default value: false.

injective : bool

Indication of injective mapping "id -> attribute". Default value: false.

Id

Numeric key.

name : string

Name of the numeric key.

Key

Complex key.

attributes : Attribute

Attributes of a complex key.

id : Id

Single numeric key column for the dictionary.

key : Key

Composite key for the dictionary, containing of one or more key columns. For details, see ClickHouse documentation.

rangeMin : Attribute

Field holding the beginning of the range for dictionaries with RANGE_HASHED layout. For details, see ClickHouse documentation.

rangeMax : Attribute

Field holding the end of the range for dictionaries with RANGE_HASHED layout. For details, see ClickHouse documentation.

attributes : Attribute

Description of the fields available for database queries. For details, see ClickHouse documentation.

Layout

Layout determining how to store the dictionary in memory.

Type
  • TYPE_UNSPECIFIED

  • FLAT

    The entire dictionary is stored in memory in the form of flat arrays. Available for all dictionary sources.

  • HASHED

    The entire dictionary is stored in memory in the form of a hash table. Available for all dictionary sources.

  • COMPLEX_KEY_HASHED

    Similar to HASHED, to be used with composite keys. Available for all dictionary sources.

  • RANGE_HASHED

    The entire dictionary is stored in memory in the form of a hash table, with an ordered array of ranges and their corresponding values. Available for all dictionary sources.

  • CACHE

    The dictionary is stored in a cache with a set number of cells. Available for MySQL, ClickHouse and HTTP dictionary sources.

  • COMPLEX_KEY_CACHE

    Similar to CACHE, to be used with composite keys. Available for MySQL, ClickHouse and HTTP dictionary sources.

type : Type

Layout type for an external dictionary.

sizeInCells : int64

Number of cells in the cache. Rounded up to a power of two. Applicable only for CACHE and COMPLEX_KEY_CACHE layout types.

maxArraySize : int64

Maximum dictionary key size. Applicable only for FLAT layout type.

Range
min : int64

Minimum dictionary lifetime.

max : int64

Maximum dictionary lifetime.

name : string

Name of the external dictionary.

structure : Structure

Set of attributes for the external dictionary. For in-depth description, see ClickHouse documentation.

layout : Layout

Layout for storing the dictionary in memory. For in-depth description, see ClickHouse documentation.

One of lifetime

Setting for the period of time between dictionary updates. For details, see ClickHouse documentation.

  • fixedLifetime : int64

    Fixed interval between dictionary updates.

  • lifetimeRange : Range

    Range of intervals between dictionary updates for ClickHouse to choose from.

One of source

Description of the source for the external dictionary.

  • httpSource : HttpSource

    HTTP source for the dictionary.

  • mysqlSource : MysqlSource

    MySQL source for the dictionary.

  • clickhouseSource : ClickhouseSource

    ClickHouse source for the dictionary.

  • mongodbSource : MongodbSource

    MongoDB source for the dictionary.

  • postgresqlSource : PostgresqlSource

    PostgreSQL source for the dictionary.

Header

name : string
value : string

Replica

host : string

MySQL host of the replica.

priority : int64

The priority of the replica that ClickHouse takes into account when connecting. Replica with the highest priority should have this field set to the lowest number.

port : int64

Port to use when connecting to the replica. If a port is not specified for a replica, ClickHouse uses the port specified for the source.

user : string

Name of the MySQL database user.

password : string

Password of the MySQL database user.

Attribute

name : string

Name of the column.

type : string

Type of the column.

nullValue : string

Default value for an element without data (for example, an empty string).

expression : string

Expression, describing the attribute, if applicable.

hierarchical : bool

Indication of hierarchy support. Default value: false.

injective : bool

Indication of injective mapping "id -> attribute". Default value: false.

Id

Numeric key.

name : string

Name of the numeric key.

Key

Complex key.

attributes : Attribute

Attributes of a complex key.

Structure

Attribute
name : string

Name of the column.

type : string

Type of the column.

nullValue : string

Default value for an element without data (for example, an empty string).

expression : string

Expression, describing the attribute, if applicable.

hierarchical : bool

Indication of hierarchy support. Default value: false.

injective : bool

Indication of injective mapping "id -> attribute". Default value: false.

Id

Numeric key.

name : string

Name of the numeric key.

Key

Complex key.

attributes : Attribute

Attributes of a complex key.

id : Id

Single numeric key column for the dictionary.

key : Key

Composite key for the dictionary, containing of one or more key columns. For details, see ClickHouse documentation.

rangeMin : Attribute

Field holding the beginning of the range for dictionaries with RANGE_HASHED layout. For details, see ClickHouse documentation.

rangeMax : Attribute

Field holding the end of the range for dictionaries with RANGE_HASHED layout. For details, see ClickHouse documentation.

attributes : Attribute

Description of the fields available for database queries. For details, see ClickHouse documentation.

Layout

Layout determining how to store the dictionary in memory.

Type
  • TYPE_UNSPECIFIED

  • FLAT

    The entire dictionary is stored in memory in the form of flat arrays. Available for all dictionary sources.

  • HASHED

    The entire dictionary is stored in memory in the form of a hash table. Available for all dictionary sources.

  • COMPLEX_KEY_HASHED

    Similar to HASHED, to be used with composite keys. Available for all dictionary sources.

  • RANGE_HASHED

    The entire dictionary is stored in memory in the form of a hash table, with an ordered array of ranges and their corresponding values. Available for all dictionary sources.

  • CACHE

    The dictionary is stored in a cache with a set number of cells. Available for MySQL, ClickHouse and HTTP dictionary sources.

  • COMPLEX_KEY_CACHE

    Similar to CACHE, to be used with composite keys. Available for MySQL, ClickHouse and HTTP dictionary sources.

type : Type

Layout type for an external dictionary.

sizeInCells : int64

Number of cells in the cache. Rounded up to a power of two. Applicable only for CACHE and COMPLEX_KEY_CACHE layout types.

maxArraySize : int64

Maximum dictionary key size. Applicable only for FLAT layout type.

Range

min : int64

Minimum dictionary lifetime.

max : int64

Maximum dictionary lifetime.

HttpSource

Header
name : string
value : string
url : string

URL of the source dictionary available over HTTP.

format : string

The data format. Valid values are all formats supported by ClickHouse SQL dialect.

headers : Header

HTTP headers.

MysqlSource

Replica
host : string

MySQL host of the replica.

priority : int64

The priority of the replica that ClickHouse takes into account when connecting. Replica with the highest priority should have this field set to the lowest number.

port : int64

Port to use when connecting to the replica. If a port is not specified for a replica, ClickHouse uses the port specified for the source.

user : string

Name of the MySQL database user.

password : string

Password of the MySQL database user.

db : string

Name of the MySQL database to connect to.

table : string

Name of the database table to use as a ClickHouse dictionary.

port : int64

Default port to use when connecting to a replica of the dictionary source.

user : string

Name of the default user for replicas of the dictionary source.

password : string

Password of the default user for replicas of the dictionary source.

replicas : Replica

List of MySQL replicas of the database used as dictionary source.

where : string

Selection criteria for the data in the specified MySQL table.

invalidateQuery : string

Query for checking the dictionary status, to pull only updated data. For more details, see ClickHouse documentation on dictionaries.

closeConnection : google.protobuf.BoolValue

Should the connection be closed after each request.

shareConnection : google.protobuf.BoolValue

Should a connection be shared for some requests.

ClickhouseSource

db : string

Name of the ClickHouse database.

table : string

Name of the table in the specified database to be used as the dictionary source.

host : string

ClickHouse host of the specified database.

port : int64

Port to use when connecting to the host.

user : string

Name of the ClickHouse database user.

password : string

Password of the ClickHouse database user.

where : string

Selection criteria for the data in the specified ClickHouse table.

secure : google.protobuf.BoolValue

Use ssl for connection.

MongodbSource

db : string

Name of the MongoDB database.

collection : string

Name of the collection in the specified database to be used as the dictionary source.

host : string

MongoDB host of the specified database.

port : int64

Port to use when connecting to the host.

user : string

Name of the MongoDB database user.

password : string

Password of the MongoDB database user.

options : string

PostgresqlSource

SslMode
  • SSL_MODE_UNSPECIFIED

  • DISABLE

    Only try a non-SSL connection.

  • ALLOW

    First try a non-SSL connection; if that fails, try an SSL connection.

  • PREFER

    First try an SSL connection; if that fails, try a non-SSL connection.

  • VERIFY_CA

    Only try an SSL connection, and verify that the server certificate is issued by a trusted certificate authority (CA).

  • VERIFY_FULL

    Only try an SSL connection, verify that the server certificate is issued by a trusted CA and that the requested server host name matches that in the certificate.

db : string

Name of the PostrgreSQL database.

table : string

Name of the table in the specified database to be used as the dictionary source.

hosts : string

Name of the PostrgreSQL host

port : int64

Port to use when connecting to the host.

user : string

Name of the PostrgreSQL database user.

password : string

Password of the PostrgreSQL database user.

invalidateQuery : string

Query for checking the dictionary status, to pull only updated data. For more details, see ClickHouse documentation on dictionaries.

sslMode : SslMode

Mode of SSL TCP/IP connection to the PostgreSQL host. For more details, see PostgreSQL documentation.

Operation

An Operation resource. For more information, see Operation.

id : string

ID of the operation.

description : string

Description of the operation. 0-256 characters long.

createdAt : google.protobuf.Timestamp

Creation timestamp.

createdBy : string

ID of the user or service account who initiated the operation.

modifiedAt : google.protobuf.Timestamp

The time when the Operation resource was last modified.

done : bool

If the value is false, it means the operation is still in progress. If true, the operation is completed, and either error or response is available.

metadata : google.protobuf.Any

Service-specific metadata associated with the operation. It typically contains the ID of the target resource that the operation is performed on. Any method that returns a long-running operation should document the metadata type, if any.

One of result

The operation result. If done == false and there was no failure detected, neither error nor response is set. If done == false and there was a failure detected, error is set. If done == true, exactly one of error or response is set.

  • error : google.rpc.Status

    The error result of the operation in case of failure or cancellation.

  • response : google.protobuf.Any
    The normal response of the operation in case of success.

    If the original method returns no data on success, such as Delete, the response is google.protobuf.Empty. If the original method is the standard Create/Update, the response should be the target resource of the operation. Any method that returns a long-running operation should document the response type, if any.