Skip to main content

ClickHouse Schema

data​

The data block defines seed/lookup data for a table.

data {
table = table.countries
rows = [
{ code = "US", name = "United States" },
{ code = "CA", name = "Canada" },
]
}

data attributes​

NameRequiredValue
rowstrue

Any value

tabletrue

Object reference to table

data constraints​

ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

dictionary​

The dictionary block describes a dictionary in a database schema.

dictionary "name" {
schema = schema.public
source = sql("CLICKHOUSE(TABLE)")
layout = sql("HASH()")
key "id" {
type = UInt64
}
attribute "name" {
type = String
}
lifetime {
min = 0
max = 0
}
...
}

dictionary attributes​

NameRequiredValue
commentfalsestring
depends_onfalse

List of object references

layouttrue

Raw expression defined with sql("expr")

schematrue

Object reference to schema

settingsfalsemap
sourcetrue

Raw expression defined with sql("expr")

dictionary blocks​

dictionary.attribute​

dictionary.attribute attributes​
NameRequiredValue
defaultfalse

Column default expression can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
nullfalsebool
typetrue

Attribute type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
dictionary.attribute constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., dictionary.attribute "name" )true

dictionary.key​

dictionary.key attributes​
NameRequiredValue
defaultfalse

Column default expression can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
nullfalsebool
typetrue

Attribute type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
dictionary.key constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., dictionary.key "name" )true

dictionary.lifetime​

dictionary.lifetime attributes​
NameRequiredValue
maxtrueint
mintrueint

dictionary constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., dictionary "name" )true
Allow Qualifier (e.g., dictionary "schema" "name" )true

function​

The function block describes a ClickHouse User-Defined Function (UDF).

function "plus_one" {
as = "(x) -> x + 1"
}

A WASM UDF sets lang and describes its module instead of an as body.

function "wasm_numbers" {
lang = WASM
returns = UInt32
module = wasm_module.math_module
source = "sub"
abi = ROW_DIRECT
deterministic = true
hash = "a957...d488"
settings = {
serialization_format = "MsgPack"
webassembly_udf_enable_fuel = 1
}
arg "a" {
type = UInt32
}
arg "b" {
type = UInt32
}
}

function attributes​

NameRequiredValue
abifalse

enum (ROW_DIRECT, BUFFERED_V1, ASSEMBLYSCRIPT)

asfalsestring
deterministicfalsebool
hashfalsestring
langfalse

enum (WASM)

modulefalse

Module name or reference can be one of:

  1. Object reference to wasm_module
  2. string
returnsfalse

Return type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
settingsfalsemap
sourcefalsestring

function blocks​

function.annotation​

function.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

function.arg​

function.arg attributes​
NameRequiredValue
typetrue

Argument type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
function.arg constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

function constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., function "name" )true
Mutually exclusive sets[as, lang]
One of required sets[as, lang]

materialized​

The materialized block describes a materialized view in a database schema.

materialized "name" {
schema = schema.public
column "total" {
null = true
type = numeric
}
...
}

materialized attributes​

NameRequiredValue
astruestring
commentfalsestring
definerfalse

User or role that defines the view can be one of:

  1. string
  2. Raw expression defined with sql("expr")
depends_onfalse

List of object references

enginefalse

Table engine can be one of:

  1. enum (MergeTree, SharedMergeTree, Memory, TimeSeries)
  2. Raw expression defined with sql("expr")
populatefalsebool
schematrue

Object reference to schema

securityfalse

enum (DEFINER, INVOKER, NONE)

tofalse

Define structure of view can be one of:

  1. Object reference to table
  2. Object reference to view

materialized blocks​

materialized.annotation​

materialized.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

materialized.column​

materialized.column attributes​
NameRequiredValue
commentfalsestring
nullfalsebool
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
materialized.column blocks​

materialized.column.annotation​

materialized.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue
materialized.column constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., materialized.column "name" )true

materialized.partition​

materialized.partition attributes​
NameRequiredValue
columnsfalse

List of object reference to column

materialized.partition blocks​

materialized.partition.on​

materialized.partition.on attributes​
NameRequiredValue
columnfalse

Object reference to column

exprfalsestring
materialized.partition.on constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[column, expr]
One of required sets[column, expr]
materialized.partition constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[columns, on]
One of required sets[columns, on]

materialized.primary_key​

materialized.primary_key attributes​
NameRequiredValue
columnsfalse

Primary key columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
materialized.primary_key blocks​

materialized.primary_key.on​

materialized.primary_key.on attributes​
NameRequiredValue
columnfalse

Primary key column can be one of:

  1. Object reference to column
  2. Object reference to table.column
exprfalsestring
materialized.primary_key.on constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[column, expr]
One of required sets[column, expr]
materialized.primary_key constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[columns, on]
One of required sets[columns, on]

materialized.refresh​

The refresh block describes the refresh settings for a materialized view.

materialized "name" {
schema = schema.public
as = sql("SELECT * FROM table")
refresh {
expr = "EVERY 1 MINUTE"
append = true
depends_on = [materialized.other_view]
settings = {
refresh_retries = 4
}
}
materialized.refresh attributes​
NameRequiredValue
appendfalsebool
depends_onfalse

List of object reference to materialized

exprtruestring
settingsfalsemap

materialized.sort​

materialized.sort attributes​
NameRequiredValue
columnsfalse

List of object reference to column

materialized.sort blocks​

materialized.sort.on​

materialized.sort.on attributes​
NameRequiredValue
columnfalse

Object reference to column

exprfalsestring
materialized.sort.on constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[column, expr]
One of required sets[column, expr]
materialized.sort constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[columns, on]
One of required sets[columns, on]

materialized constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., materialized "name" )true
Allow Qualifier (e.g., materialized "schema" "name" )true
Mutually exclusive sets[to, engine], [to, populate]
One of required sets[to, engine]

named_collection​

The named_collection block describes a ClickHouse named collection (key-value store).

named_collection "my_conn" {
item "host" {
value = "127.0.0.1"
overridable = ALLOW // OVERRIDABLE
}
item "port" {
value = 5432
overridable = DENY // NOT OVERRIDABLE
}
item "user" {
value = "admin"
}
item "use_ssl" {
value = 1
}
}

An item with no overridable is not DENY: the server decides whether a query may override it, by its allow_named_collection_override_by_default setting. Managing the modifier requires ClickHouse 25.5 or above.

named_collection blocks​

named_collection.item​

named_collection.item attributes​
NameRequiredValue
overridablefalse

Override modifier can be one of:

  1. enum (ALLOW, DENY)
  2. string
valuetrue

Any value

named_collection.item constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

named_collection constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., named_collection "name" )true

permission​

The permission block describes permissions (privileges) granted on database objects.

permission {
to = "user1"
for = table.users
privileges = [SELECT]
}

permission {
to = "admin"
for = schema.public
privileges = [ALL]
grantable = true
}

permission attributes​

NameRequiredValue
fortrue

Permission target resource can be one of:

  1. Object reference to schema
  2. Object reference to table
  3. Object reference to view
  4. Object reference to materialized
  5. Object reference to dictionary
  6. Object reference to function
  7. Object reference to named_collection
  8. Object reference to table.column
  9. Object reference to view.column
  10. Object reference to materialized.column
grantablefalsebool
privilegestrue

List of strings or/and enums (SELECT, INSERT, ALTER, ALTER_DATABASE, ALTER_DATABASE_SETTINGS, ALTER_TABLE, ALTER_COLUMN, ALTER_ADD_COLUMN, ALTER_DROP_COLUMN, ALTER_MODIFY_COLUMN, ALTER_COMMENT_COLUMN, ALTER_CLEAR_COLUMN, ALTER_RENAME_COLUMN, ALTER_MATERIALIZE_COLUMN, ALTER_INDEX, ALTER_ADD_INDEX, ALTER_DROP_INDEX, ALTER_MATERIALIZE_INDEX, ALTER_CLEAR_INDEX, ALTER_ORDER_BY, ALTER_SAMPLE_BY, ALTER_CONSTRAINT, ALTER_ADD_CONSTRAINT, ALTER_DROP_CONSTRAINT, ALTER_TTL, ALTER_MATERIALIZE_TTL, ALTER_SETTINGS, ALTER_MOVE_PARTITION, ALTER_FETCH_PARTITION, ALTER_FREEZE_PARTITION, ALTER_PROJECTION, ALTER_STATISTICS, ALTER_ADD_STATISTICS, ALTER_DROP_STATISTICS, ALTER_MATERIALIZE_STATISTICS, ALTER_MODIFY_STATISTICS, ALTER_DELETE, ALTER_UPDATE, ALTER_MODIFY_COMMENT, ALTER_VIEW, ALTER_VIEW_MODIFY_QUERY, ALTER_VIEW_REFRESH, ALTER_VIEW_MODIFY_SQL_SECURITY, CREATE, CREATE_DATABASE, CREATE_TABLE, CREATE_ARBITRARY_TEMPORARY_TABLE, CREATE_TEMPORARY_TABLE, CREATE_VIEW, CREATE_DICTIONARY, CREATE_FUNCTION, CREATE_RESOURCE, CREATE_WORKLOAD, DROP, DROP_DATABASE, DROP_TABLE, DROP_VIEW, DROP_DICTIONARY, DROP_FUNCTION, DROP_RESOURCE, DROP_WORKLOAD, UNDROP_TABLE, TRUNCATE, OPTIMIZE, BACKUP, SHOW, SHOW_DATABASES, SHOW_TABLES, SHOW_COLUMNS, SHOW_DICTIONARIES, SHOW_FILESYSTEM_CACHES, KILL_QUERY, KILL_TRANSACTION, MOVE_PARTITION_BETWEEN_SHARDS, CLUSTER, ACCESS_MANAGEMENT, CREATE_USER, ALTER_USER, DROP_USER, CREATE_ROLE, ALTER_ROLE, DROP_ROLE, ROLE_ADMIN, CREATE_ROW_POLICY, ALTER_ROW_POLICY, DROP_ROW_POLICY, CREATE_QUOTA, ALTER_QUOTA, DROP_QUOTA, CREATE_SETTINGS_PROFILE, ALTER_SETTINGS_PROFILE, DROP_SETTINGS_PROFILE, SHOW_ACCESS, SHOW_USERS, SHOW_ROLES, SHOW_ROW_POLICIES, SHOW_QUOTAS, SHOW_SETTINGS_PROFILES, ALLOW_SQL_SECURITY_NONE, SYSTEM, SYSTEM_SHUTDOWN, SYSTEM_DROP_CACHE, SYSTEM_DROP_DNS_CACHE, SYSTEM_DROP_MARK_CACHE, SYSTEM_DROP_UNCOMPRESSED_CACHE, SYSTEM_DROP_COMPILED_EXPRESSION_CACHE, SYSTEM_DROP_CONNECTIONS_CACHE, SYSTEM_DROP_DISTRIBUTED_CACHE, SYSTEM_DROP_FILESYSTEM_CACHE, SYSTEM_DROP_FORMAT_SCHEMA_CACHE, SYSTEM_DROP_MMAP_CACHE, SYSTEM_DROP_PAGE_CACHE, SYSTEM_DROP_PRIMARY_INDEX_CACHE, SYSTEM_DROP_QUERY_CACHE, SYSTEM_DROP_S3_CLIENT_CACHE, SYSTEM_DROP_SCHEMA_CACHE, SYSTEM_DROP_REPLICA, SYSTEM_FAILPOINT, SYSTEM_FETCHES, SYSTEM_FLUSH, SYSTEM_FLUSH_ASYNC_INSERT_QUEUE, SYSTEM_FLUSH_LOGS, SYSTEM_FLUSH_DISTRIBUTED, SYSTEM_JEMALLOC, SYSTEM_KILL_QUERY, SYSTEM_KILL_TRANSACTION, SYSTEM_LISTEN, SYSTEM_LOAD_PRIMARY_KEY, SYSTEM_MERGES, SYSTEM_MOVES, SYSTEM_PULLING_REPLICATION_LOG, SYSTEM_REDUCE_BLOCKING_PARTS, SYSTEM_REPLICATION_QUEUES, SYSTEM_REPLICA_READINESS, SYSTEM_RESTART_DISK, SYSTEM_RESTART_REPLICA, SYSTEM_RESTORE_REPLICA, SYSTEM_RELOAD, SYSTEM_RELOAD_ASYNCHRONOUS_METRICS, SYSTEM_RELOAD_CONFIG, SYSTEM_RELOAD_DICTIONARY, SYSTEM_RELOAD_EMBEDDED_DICTIONARIES, SYSTEM_RELOAD_FUNCTION, SYSTEM_RELOAD_MODEL, SYSTEM_RELOAD_USERS, SYSTEM_SENDS, SYSTEM_DISTRIBUTED_SENDS, SYSTEM_REPLICATED_SENDS, SYSTEM_SYNC_DATABASE_REPLICA, SYSTEM_SYNC_FILE_CACHE, SYSTEM_SYNC_FILESYSTEM_CACHE, SYSTEM_SYNC_REPLICA, SYSTEM_SYNC_TRANSACTION_LOG, SYSTEM_THREAD_FUZZER, SYSTEM_TTL_MERGES, SYSTEM_UNFREEZE, SYSTEM_UNLOAD_PRIMARY_KEY, SYSTEM_VIEWS, SYSTEM_VIRTUAL_PARTS_UPDATE, SYSTEM_WAIT_LOADING_PARTS, SYSTEM_CLEANUP, INTROSPECTION, addressToLine, addressToLineWithInlines, addressToSymbol, demangle, READ, WRITE, AZURE, FILE, HDFS, HIVE, JDBC, KAFKA, MONGO, MYSQL, NATS, ODBC, POSTGRES, RABBITMQ, REDIS, REMOTE, S3, SQLITE, URL, dictGet, displaySecretsInShowAndSelect, SET_DEFINER, NAMED_COLLECTION_ADMIN, CREATE_NAMED_COLLECTION, DROP_NAMED_COLLECTION, ALTER_NAMED_COLLECTION, SHOW_NAMED_COLLECTIONS, SHOW_NAMED_COLLECTIONS_SECRETS, NAMED_COLLECTION, TABLE_ENGINE, ALL, NONE)

totrue

Role or user can be one of:

  1. string
  2. Object reference to role
  3. Object reference to user

permission constraints​

ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

policy​

The policy block describes a ClickHouse row-level security policy.

policy "filter_tenant" {
schema = schema.public
on = table.users
using = "tenant_id = 1"
to = [role.admin]
restrictive = true
}

policy attributes​

NameRequiredValue
ontrue

Table or view the policy applies to can be one of:

  1. Object reference to table
  2. string
restrictivefalsebool
tofalse

List of values, where each can be one of:

  1. Object reference to role
  2. Object reference to user
  3. string
to_allfalsebool
to_all_exceptfalse

List of values, where each can be one of:

  1. Object reference to role
  2. Object reference to user
  3. string
usingfalsestring

policy constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., policy "name" )true
Allow Qualifier (e.g., policy "schema" "name" )true
Mutually exclusive sets[to, to_all, to_all_except]
One of required sets[to, to_all, to_all_except]

role​

The role block describes a database role.

role "admin" {
storage = "local_directory"
member_of = [role.viewer]
}

role attributes​

NameRequiredValue
member_offalse

List of object references

storagefalse

enum (users_xml, ldap, local_directory, replicated, memory)

role blocks​

role.membership​

The membership block describes a membership in a role, along with its options.

user "vault" {
membership {
role = role.reader
admin = true
}
}
role.membership attributes​
NameRequiredValue
adminfalsebool
roletrue

Object reference to role

role.membership constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

role.settings_profile​

role.settings_profile attributes​
NameRequiredValue
inheritfalse

List of values, where each can be one of:

  1. Object reference to settings_profile
  2. string
role.settings_profile blocks​

role.settings_profile.setting​

role.settings_profile.setting attributes​
NameRequiredValue
maxfalse

Any value

minfalse

Any value

valuetrue

Any value

writabilityfalse

Writability constraint can be one of:

  1. enum (WRITABLE, CONST, CHANGEABLE_IN_READONLY)
  2. string
role.settings_profile.setting constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

role constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., role "name" )true
Repeatabletrue

schema​

The schema block describes a database schema.

schema "public" {
...
}

schema attributes​

NameRequiredValue
commentfalsestring
enginefalse

Schema engine can be one of:

  1. enum (Atomic, Lazy)
  2. Raw expression defined with sql("expr")
namefalsestring
settingsfalsemap

schema blocks​

schema.annotation​

schema.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

schema constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., schema "name" )true

settings_profile​

The settings_profile block describes a ClickHouse settings profile (realm-level access entity).

settings_profile "readonly" {
setting "max_memory_usage" {
value = 10000000000
writability = "CONST"
}
inherit = ["default"]
to = [role.analyst]
}

settings_profile attributes​

NameRequiredValue
inheritfalse

List of values, where each can be one of:

  1. Object reference to settings_profile
  2. string
tofalse

List of values, where each can be one of:

  1. Object reference to role
  2. Object reference to user
  3. string
to_allfalsebool
to_all_exceptfalse

List of values, where each can be one of:

  1. Object reference to role
  2. Object reference to user
  3. string

settings_profile blocks​

settings_profile.setting​

settings_profile.setting attributes​
NameRequiredValue
maxfalse

Any value

minfalse

Any value

valuetrue

Any value

writabilityfalse

Writability constraint can be one of:

  1. enum (WRITABLE, CONST, CHANGEABLE_IN_READONLY)
  2. string
settings_profile.setting constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

settings_profile constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., settings_profile "name" )true
Mutually exclusive sets[to, to_all, to_all_except]

table​

The table block describes a table in a database schema.

table "users" {
schema = schema.public
column "id" {
type = int
}
...
}

table attributes​

NameRequiredValue
commentfalsestring
depends_onfalse

List of object references

enginefalse

Table engine can be one of:

  1. enum (MergeTree, SharedMergeTree, Memory, TimeSeries)
  2. Raw expression defined with sql("expr")
renamed_fromfalsestring
schematrue

Object reference to schema

settingsfalsemap
ttlfalse

Column ttl can be one of:

  1. string
  2. Raw expression defined with sql("expr")

table blocks​

table.annotation​

table.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

table.check​

table.check attributes​
NameRequiredValue
assumefalsebool
commentfalsestring
exprtruestring
table.check constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

table.column​

table.column attributes​
NameRequiredValue
codecfalse

Column codec can be one of:

  1. string
  2. Raw expression defined with sql("expr")
  3. enum (NONE, ZSTD, LZ4, LZ4HC, DoubleDelta, Gorilla, FPC, T64, AES_128_GCM_SIV, AES_256_GCM_SIV)
commentfalsestring
defaultfalse

Column default expression can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
default_kindfalse

Column default kind can be one of:

  1. enum (DEFAULT, MATERIALIZED, EPHEMERAL, ALIAS)
nullfalsebool
renamed_fromfalsestring
ttlfalse

Column ttl can be one of:

  1. string
  2. Raw expression defined with sql("expr")
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
table.column blocks​

table.column.annotation​

table.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue
table.column constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., table.column "name" )true
Repeatabletrue

table.engine.TimeSeries​

table.engine.TimeSeries attributes​
NameRequiredValue
datafalse

Object reference to table

metricsfalse

Object reference to table

tagsfalse

Object reference to table

table.index​

table.index attributes​
NameRequiredValue
commentfalsestring
granularityfalseint
typetrue

Index type can be one of:

  1. Raw expression defined with sql("expr")
  2. string
  3. enum (minmax, bloom_filter)
table.index blocks​

table.index.on​

table.index.on attributes​
NameRequiredValue
exprtruestring
table.index.on constraints​
ConstraintValue
Requiredtrue
Require Namefalse
table.index constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., table.index "name" )true

table.partition​

table.partition attributes​
NameRequiredValue
columnsfalse

List of object reference to column

table.partition blocks​

table.partition.on​

table.partition.on attributes​
NameRequiredValue
columnfalse

Object reference to column

exprfalsestring
table.partition.on constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[column, expr]
One of required sets[column, expr]
table.partition constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[columns, on]
One of required sets[columns, on]

table.primary_key​

table.primary_key attributes​
NameRequiredValue
columnsfalse

Primary key columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
table.primary_key blocks​

table.primary_key.on​

table.primary_key.on attributes​
NameRequiredValue
columnfalse

Primary key column can be one of:

  1. Object reference to column
  2. Object reference to table.column
exprfalsestring
table.primary_key.on constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[column, expr]
One of required sets[column, expr]
table.primary_key constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[columns, on]
One of required sets[columns, on]

table.projection​

The projection block describes a projection for a table

table "name" {
schema = schema.public
projection "name" {
as = "SELECT * FROM table WHERE condition"
}
projection "another" {
as = "SELECT * FROM table WHERE another_condition"
}
}
table.projection attributes​
NameRequiredValue
astruestring
table.projection constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

table.sort​

table.sort attributes​
NameRequiredValue
columnsfalse

List of object reference to column

table.sort blocks​

table.sort.on​

table.sort.on attributes​
NameRequiredValue
columnfalse

Object reference to column

exprfalsestring
table.sort.on constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[column, expr]
One of required sets[column, expr]
table.sort constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[columns, on]
One of required sets[columns, on]

table constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., table "name" )true
Allow Qualifier (e.g., table "schema" "name" )true

user​

The user block describes a database user.

user "john" {
auth_type = "sha256_password"
member_of = [role.admin]
}

user attributes​

NameRequiredValue
auth_typefalsestring
member_offalse

List of object references

passwordfalsestring
storagefalse

enum (users_xml, ldap, local_directory, replicated, memory)

user blocks​

user.membership​

The membership block describes a membership in a role, along with its options.

user "vault" {
membership {
role = role.reader
admin = true
}
}
user.membership attributes​
NameRequiredValue
adminfalsebool
roletrue

Object reference to role

user.membership constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

user.settings_profile​

user.settings_profile attributes​
NameRequiredValue
inheritfalse

List of values, where each can be one of:

  1. Object reference to settings_profile
  2. string
user.settings_profile blocks​

user.settings_profile.setting​

user.settings_profile.setting attributes​
NameRequiredValue
maxfalse

Any value

minfalse

Any value

valuetrue

Any value

writabilityfalse

Writability constraint can be one of:

  1. enum (WRITABLE, CONST, CHANGEABLE_IN_READONLY)
  2. string
user.settings_profile.setting constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

user constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., user "name" )true
Repeatabletrue

view​

The view block describes a view in a database schema.

view "clean_users" {
schema = schema.public
column "id" {
type = int
}
...
}

view attributes​

NameRequiredValue
astruestring
commentfalsestring
definerfalse

User or role that defines the view can be one of:

  1. string
  2. Raw expression defined with sql("expr")
depends_onfalse

List of object references

schematrue

Object reference to schema

securityfalse

enum (DEFINER, INVOKER, NONE)

view blocks​

view.annotation​

view.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

view.column​

view.column attributes​
NameRequiredValue
commentfalsestring
nullfalsebool
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
view.column blocks​

view.column.annotation​

view.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue
view.column constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., view.column "name" )true

view constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., view "name" )true
Allow Qualifier (e.g., view "schema" "name" )true
Mutually exclusive sets[latest, git]

wasm_module​

The wasm_module block describes a ClickHouse WASM module (realm-level object).

wasm_module "my_module" {
code = sql("unhex('0061736d0100...')") // Expression producing the wasm binary.
hash = sql("reinterpretAsUInt256(unhex('369f...c57d'))") // Optional integrity hash expression.
}

The module code is write-only: inspection emits only the hash attribute (absent while the module is not yet loaded). code is required in desired states.

wasm_module attributes​

NameRequiredValue
codetrue

Raw expression defined with sql("expr")

hashfalse

Raw expression defined with sql("expr")

wasm_module constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., wasm_module "name" )true