Skip to main content
For dictionaries created with DDL queries, the dict_name parameter must be fully specified, like <database>.<dict_name>. Otherwise, the current database is used.
For information on connecting and configuring dictionaries, see Dictionaries.

Example dictionaries

The examples in this section make use of the following dictionaries. You can create them in ClickHouse to run the examples for the functions described below.
Create a table to store the data for the regexp tree dictionary:
Insert data into the table:
Create the regexp tree dictionary:
Create the input table:
Insert the data into the input table:
Create the dictionary:
Create the source table:
Insert the data into the source table:
Create the dictionary:
Create the source table:
Insert the data into the source table:
Create the dictionary:

Passing keys to dictionary functions

The key argument (id_expr) of functions such as dictGet, dictGetOrDefault, dictGetOrNull and dictHas depends on the dictionary’s key:
  • For a dictionary with a simple key (UInt64), pass the key value directly:
  • For a dictionary with a composite (complex) key of more than one attribute, pass the key values as a tuple:
  • When the composite key consists of a single attribute, the key value can be passed directly, without wrapping it in tuple. Both of the following are valid and equivalent:
This also applies to ip_trie dictionaries, whose key is a single attribute. The IP address to look up can be passed directly:

dictGet

Introduced in: v18.16.0 Retrieves values from a dictionary.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_names — Name of the column of the dictionary, or tuple of column names. String or Tuple(String)
  • id_expr — Key value. For a dictionary with a simple key, an expression returning a UInt64 value. For a dictionary with a composite (complex) key, an expression returning a tuple of the key values. If the composite key consists of a single attribute, its value may be passed directly, without wrapping it in tuple. UInt64 or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr if the key is found. If the key is not found, returns the content of the <null_value> element specified for the attribute in the dictionary configuration. Examples Retrieve a single attribute
Query
Response
Multiple attributes
Query
Response

dictGetAll

Introduced in: v23.5.0 Retrieves the attribute values of all the nodes that matched each key in a regular expression tree dictionary. Besides returning values of type Array(T) instead of T, this function behaves similarly to dictGet.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_names — Name of the column of the dictionary, or tuple of column names. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • limit — Optional. Maximum length for each value array returned. When truncating, child nodes are given precedence over parent nodes, and otherwise the defined list order for the regexp tree dictionary is respected. If unspecified, the array length is unlimited. UInt*
Returned value Returns an array of the dictionary attribute values that correspond to id_expr for each attribute specified by attr_names. If there is no key corresponding to id_expr in the dictionary, an empty array is returned.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Array(T) Examples Usage example
Query
Response

dictGetChildren

Introduced in: v21.4.0 Returns first-level children as an array of indexes. It is the inverse transformation for dictGetHierarchy.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments Returned value Returns the first-level descendants for the key. Array(UInt64) Examples Get the first-level children of a dictionary
Query
Response

dictGetDate

Introduced in: v1.1.0 Converts a dictionary attribute value to Date data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetDateOrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to Date data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetDateTime

Introduced in: v1.1.0 Converts a dictionary attribute value to DateTime data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetDateTimeOrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to DateTime data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetDescendants

Introduced in: v21.4.0 Returns all descendants as if the dictGetChildren function were applied level times recursively.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • key — Key to be checked. const String
  • level — Key to be checked. Hierarchy level. If level = 0 returns all descendants to the end. UInt8
Returned value Returns the descendants for the key. Array(UInt64) Examples Get the first-level children of a dictionary
Query
Response

dictGetFloat32

Introduced in: v1.1.0 Converts a dictionary attribute value to Float32 data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetFloat32OrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to Float32 data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetFloat64

Introduced in: v1.1.0 Converts a dictionary attribute value to Float64 data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetFloat64OrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to Float64 data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetHierarchy

Introduced in: v1.1.0 Creates an array, containing all the parents of a key in the hierarchical dictionary.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments Returned value Returns parents for the key. Array(UInt64) Examples Get hierarchy for a key
Query
Response

dictGetIPv4

Introduced in: v1.1.0 Converts a dictionary attribute value to IPv4 data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetIPv4OrDefault

Introduced in: v23.1.0 Converts a dictionary attribute value to IPv4 data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetIPv6

Introduced in: v23.1.0 Converts a dictionary attribute value to IPv6 data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetIPv6OrDefault

Introduced in: v23.1.0 Converts a dictionary attribute value to IPv6 data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetInt16

Introduced in: v1.1.0 Converts a dictionary attribute value to Int16 data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetInt16OrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to Int16 data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetInt32

Introduced in: v1.1.0 Converts a dictionary attribute value to Int32 data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetInt32OrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to Int32 data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetInt64

Introduced in: v1.1.0 Converts a dictionary attribute value to Int64 data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetInt64OrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to Int64 data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetInt8

Introduced in: v1.1.0 Converts a dictionary attribute value to Int8 data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetInt8OrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to Int8 data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetKeys

Introduced in: v25.12.0 Returns the dictionary key(s) whose attribute equals the specified value. This is the inverse of the function dictGet on a single attribute. Use setting max_reverse_dictionary_lookup_cache_size_bytes to cap the size of the per-query reverse-lookup cache used by dictGetKeys. The cache stores serialized key tuples for each attribute value to avoid re-scanning the dictionary within the same query. The cache is not persistent across queries. When the limit is reached, entries are evicted with LRU. This is most effective with large dictionaries when the input has low cardinality and the working set fits in the cache. Set to 0 to disable caching.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Attribute to match. String
  • value_expr — Value to match against the attribute. Expression
Returned value For single key dictionaries: an array of keys whose attribute equals value_expr. For multi key dictionaries: an array of tuples of keys whose attribute equals value_expr. If there is no attribute corresponding to value_expr in the dictionary, then an empty array is returned. ClickHouse throws an exception if it cannot parse the value of the attribute or the value cannot be converted to the attribute data type. Examples Sample usage
Query
Response

dictGetOrDefault

Introduced in: v18.16.0 Retrieves values from a dictionary, with a default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_names — Name of the column of the dictionary, or tuple of column names. String or Tuple(String)
  • id_expr — Key value. For a dictionary with a simple key, an expression returning a UInt64 value. For a dictionary with a composite (complex) key, an expression returning a tuple of the key values. If the composite key consists of a single attribute, its value may be passed directly, without wrapping it in tuple. UInt64 or Tuple(T)
  • default_value — Default value to return if the key is not found. Type must match the attribute’s data type.
Returned value Returns the value of the dictionary attribute that corresponds to id_expr if the key is found. If the key is not found, returns the default_value provided. Examples Get value with default
Query
Response

dictGetOrNull

Introduced in: v21.4.0 Retrieves values from a dictionary, returning NULL if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String literal. - attr_name — Name of the column to retrieve. String literal. - id_expr — Key value. Expression returning dictionary key-type value.
Returned value Returns the value of the dictionary attribute that corresponds to id_expr if the key is found. If the key is not found, returns NULL. Examples Example using the range key dictionary
Query
Response

dictGetString

Introduced in: v1.1.0 Converts a dictionary attribute value to String data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetStringOrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to String data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetUInt16

Introduced in: v1.1.0 Converts a dictionary attribute value to UInt16 data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetUInt16OrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to UInt16 data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetUInt32

Introduced in: v1.1.0 Converts a dictionary attribute value to UInt32 data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetUInt32OrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to UInt32 data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetUInt64

Introduced in: v1.1.0 Converts a dictionary attribute value to UInt64 data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetUInt64OrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to UInt64 data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetUInt8

Introduced in: v1.1.0 Converts a dictionary attribute value to UInt8 data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetUInt8OrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to UInt8 data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetUUID

Introduced in: v1.1.0 Converts a dictionary attribute value to UUID data type regardless of the dictionary configuration.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. An expression returning a dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the content of the <null_value> element specified for the attribute in the dictionary configuration.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictGetUUIDOrDefault

Introduced in: v1.1.0 Converts a dictionary attribute value to UUID data type regardless of the dictionary configuration, or returns the provided default value if the key is not found.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • attr_name — Name of the column of the dictionary. String or Tuple(String)
  • id_expr — Key value. Expression returning dictionary key-type value or tuple value (dictionary configuration dependent). Expression or Tuple(T)
  • default_value_expr — Value(s) returned if the dictionary does not contain a row with the id_expr key. Expression or Tuple(T)
Returned value Returns the value of the dictionary attribute that corresponds to id_expr, otherwise returns the value passed as the default_value_expr parameter.
ClickHouse throws an exception if it cannot parse the value of the attribute or the value does not match the attribute data type.
Examples Usage example
Query
Response

dictHas

Introduced in: v1.1.0 Checks whether a key is present in a dictionary.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments Returned value Returns 1 if the key exists, otherwise 0. UInt8 Examples Check for the existence of a key in a dictionary
Query
Response

dictIsIn

Introduced in: v1.1.0 Checks the ancestor of a key through the whole hierarchical chain in the dictionary.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • dict_name — Name of the dictionary. String
  • child_id_expr — Key to be checked. String
  • ancestor_id_expr — Alleged ancestor of the child_id_expr key. const String
Returned value Returns 0 if child_id_expr is not a child of ancestor_id_expr, 1 if child_id_expr is a child of ancestor_id_expr or if child_id_expr is an ancestor_id_expr. UInt8 Examples Check hierarchical relationship
Query
Response
Last modified on July 2, 2026