DataLakeCatalog database engine enables you to connect ClickHouse to external
data catalogs and query open table format data without the need for data duplication.
This transforms ClickHouse into a powerful query engine that works seamlessly with
your existing data lake infrastructure.
Supported catalogs
TheDataLakeCatalog engine supports the following data catalogs:
- AWS Glue Catalog - For Iceberg tables in AWS environments
- Databricks Unity Catalog - For Delta Lake and Iceberg tables
- Hive Metastore - Traditional Hadoop ecosystem catalog
- REST Catalogs - Any catalog supporting the Iceberg REST specification
Creating a database
You will need to enable the relevant settings below to use theDataLakeCatalog engine:
DataLakeCatalog engine can be created using the following syntax:
Referencing tables in namespaces
Namespace-aware name resolution is an experimental feature, disabled by default. Enable it
with
SET enable_table_namespaces = 1. A dotted path such as
catalog_name.namespace.table is shorthand for the quoted form
catalog_name.`namespace.table` and needs the setting in a query that reads from it; without the
setting such a query is rejected and the quoted form has to be used. Statements that name their target
table (INSERT, CREATE, DROP, ALTER, DESCRIBE and similar) accept the path regardless of the
setting. A stored definition, such as the query of a view or a materialized view, is checked like a
query each time it is analysed, starting with the CREATE statement; see below.namespace.table (or namespace1.namespace2.table for a nested namespace),
and it can always be referenced by quoting that name as a single identifier:
db.ns.table(three or more parts) in a table expression requiresenable_table_namespacesand is read as the table pathns.tableinside databasedb; it is then subject to the same two-part rule asa.bbelow, witha=db.- With
enable_table_namespacesenabled, a two-part namea.bin a table expression is resolved as tablebof databasea, and also as tablea.bof the current database if that database supports table namespaces (a data lake catalog) andais notsystem. A catalog namespace namedsystemis referenced as`system.t`orcatalog_name.system.t. Databaseamust exist; when only one of the two tables exists it is used, and when both exist and the user can access both, the query fails withAMBIGUOUS_IDENTIFIER; if the user can access only one, that one is used. Other statements (EXISTS,DESCRIBE,INSERT,SHOW CREATE TABLE, DDL) always reada.bas databasea, tableb. - SQL stored in definitions (view and materialized view bodies, row policy
conditions, mutations, column
DEFAULT/MATERIALIZED/ALIASexpressions,ClickHousedictionary source queries executed on the same server, SQL function bodies, the input queries of anExecutableorExecutablePooltable, the query argument of the table function when a table created withCREATE TABLE ... AS f(...)is read) always readsa.bas databasea, tableb; the query argument of table functionsview,viewIfPermitted,eval,obfuscate,explainandexecutablethat such SQL calls keeps the two-part rule. In a stored definition, reference a catalog table ascatalog_name.`ns.t`. The path formcatalog_name.ns.tneedsenable_table_namespaceseach time the definition is analysed, with the settings in effect there: those of the user who creates the view, reads it, or inserts into the source table of a materialized view. A tableTTLis analysed with the server settings, and a refreshable materialized view is not refreshed with the settings of the session that created it, so a session setting does not apply to them. To make a definition independent of these settings, use the quoted name or addSETTINGS enable_table_namespaces = 1to the query inside it; the clause is ignored for a user withreadonly = 1, the quoted name works for everyone. A definition is written to disk with the quoted name, so after a restart orATTACHa path in a table expression of it no longer needs the setting, while a path as the right operand ofIN(x IN catalog_name.ns.t) and as a column qualifier (catalog_name.ns.t.x) is stored as written and still needs it. A dictionaryQUERYis kept as text, runs in the dictionary’s own context and needs the setting in the query’s ownSETTINGSclause. In view bodies and column expressions,`ns.t`also works when the catalog is the current database at creation: it is qualified then and stored ascatalog_name.`ns.t`.
SELECT, INSERT, CREATE TABLE, DROP TABLE,
ALTER TABLE, RENAME TABLE, OPTIMIZE TABLE, CHECK TABLE, SYSTEM commands,
EXISTS TABLE, DESCRIBE, SHOW CREATE TABLE, SHOW COLUMNS and SHOW INDEXES.
It is not accepted in BACKUP / RESTORE table lists, in access-control statements
(GRANT, row and masking policies) or as the table argument of the remote table
function; use the quoted form there. With the setting enabled, a column qualifier may
spell the table path the same way: SELECT namespace.table.column FROM catalog_name.namespace.table.
A back-quoted component containing a dot spells the same path as the separate
parts, exactly as for column names: catalog_name.`a.b`.table,
catalog_name.a.b.table and catalog_name.`a.b.table` denote the same
table. Catalog objects whose native names contain literal dots cannot be told
apart from nested paths, because the catalogs themselves spell nested namespaces
with dots.
Examples
See below sections for examples of using theDataLakeCatalog engine:
- Unity Catalog
- Unity Catalog with Delta Lake and Iceberg tables
With
use_unity_catalog_v2 = 1, theunitycatalog serves both Delta Lake and Iceberg tables, detecting the format of each table.
catalog_credential accepts an OAuth service principal as <client_id>:<client_secret>,
a personal access token (dapi...), or a pre-obtained OAuth token.
- Glue Catalog
- OneLake Catalog
Can be used by enabling
allow_database_iceberg.
onelake_bearer_token to a pre-obtained
bearer token (scoped to https://storage.azure.com) instead of
onelake_client_id/onelake_client_secret. ClickHouse does not refresh the token, so the
database must be recreated after it expires.