> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-sync-clickhouse-operator-docs-7e82242.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Connecting to a data catalog

> Connect ClickHouse to external data catalogs using the DataLakeCatalog database engine to expose catalog tables as native ClickHouse databases.

export const BetaBadge = () => {
  return <div className="betaBadge">
            <div className="betaIcon">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path strokeWidth="1.25" d="M7.35227 6.72731H8.29924C8.96212 6.72731 9.50189 6.86778 9.91856 7.14871C10.3384 7.42965 10.6461 7.78634 10.8419 8.21879C11.0407 8.65124 11.1402 9.09474 11.1402 9.54928C11.1402 10.0985 11.0123 10.5941 10.7566 11.036C10.5009 11.4748 10.149 11.8236 9.70076 12.0824C9.25253 12.3381 8.74116 12.4659 8.16667 12.4659C7.81629 12.4659 7.46907 12.4012 7.125 12.2718C6.78409 12.1392 6.48106 11.8883 6.21591 11.519L6.14015 11.5569V9.7008C6.14015 10.0101 6.21591 10.2958 6.36742 10.5578C6.5221 10.8198 6.7399 11.0297 7.02083 11.1875C7.30492 11.3454 7.64268 11.4243 8.03409 11.4243C8.44444 11.4243 8.79798 11.3375 9.0947 11.1639C9.39141 10.9903 9.62027 10.7614 9.78125 10.4773C9.94224 10.1932 10.0227 9.88388 10.0227 9.54928C10.0227 9.23363 9.95013 8.93533 9.80492 8.6544C9.66288 8.37031 9.46086 8.13988 9.19886 7.96311C8.94003 7.78318 8.63384 7.69322 8.2803 7.69322H7.35227V6.72731ZM7.90152 2.50383C8.3529 2.50383 8.75221 2.57643 9.09943 2.72163C9.44981 2.86683 9.74495 3.06254 9.98485 3.30875C10.2279 3.55181 10.411 3.82485 10.5341 4.12788C10.6604 4.43091 10.7235 4.74183 10.7235 5.06065C10.7235 5.45837 10.6225 5.85452 10.4205 6.24909C10.2184 6.64051 9.90909 6.96721 9.49242 7.22921C9.07576 7.48805 8.54546 7.61746 7.90152 7.61746H7.35227V6.65156H7.88258C8.24874 6.65156 8.56124 6.5758 8.82008 6.42428C9.08207 6.27277 9.28093 6.07548 9.41667 5.83243C9.55556 5.58937 9.625 5.33211 9.625 5.06065C9.625 4.62504 9.4577 4.26361 9.12311 3.97637C8.79167 3.68912 8.38447 3.54549 7.90152 3.54549C7.57955 3.54549 7.28441 3.61178 7.0161 3.74436C6.75095 3.87693 6.53788 4.06159 6.37689 4.29834C6.21907 4.53508 6.14015 4.80812 6.14015 5.11746V15.0606H5.02273V5.11746C5.02273 4.61873 5.14583 4.17207 5.39205 3.7775C5.64141 3.38293 5.98232 3.07201 6.41477 2.84474C6.85038 2.61746 7.34596 2.50383 7.90152 2.50383Z" />
            </svg>
        </div>
            <span>
                Beta feature. 
                <u>
                    <a href="/docs/beta-and-experimental-features#beta-features">
                        Learn more.
                    </a>
                </u>
            </span>
        </div>;
};

In the [previous section](/core/guides/use-cases/data-warehousing/getting-started/querying-directly), you queried open table formats by passing storage paths directly. In practice, most organizations manage table metadata through a **data catalog** - a central registry that tracks table locations, schemas, and partitions. When you connect ClickHouse to a catalog using the [`DataLakeCatalog`](/core/reference/engines/database-engines/datalake) database engine, the entire catalog is exposed as a ClickHouse database. Every table in the catalog appears automatically and can be queried with full ClickHouse SQL - no need to know individual table paths or manage credentials per table.

This guide walks through connecting to [Databricks Unity Catalog](https://www.databricks.com/product/unity-catalog). ClickHouse also supports the following catalogs - refer to each reference guide for full setup instructions:

| Catalog              | Reference guide                                                                  |
| -------------------- | -------------------------------------------------------------------------------- |
| AWS Glue             | [AWS Glue catalog](/core/guides/use-cases/data-warehousing/glue-catalog)         |
| Iceberg REST Catalog | [REST catalog](/core/guides/use-cases/data-warehousing/rest-catalog)             |
| Lakekeeper           | [Lakekeeper catalog](/core/guides/use-cases/data-warehousing/lakekeeper-catalog) |
| Project Nessie       | [Nessie catalog](/core/guides/use-cases/data-warehousing/nessie-catalog)         |
| Microsoft OneLake    | [Fabric OneLake](/core/guides/use-cases/data-warehousing/onelake-catalog)        |

<h2 id="connecting-to-unity-catalog">
  Connecting to a Unity Catalog
</h2>

For example purposes, we'll use the Unity catalog.

[Databricks Unity Catalog](https://www.databricks.com/product/unity-catalog) provides centralized governance for Databricks lakehouse data.

Databricks supports multiple data formats for their lakehouse. With ClickHouse, you can query Unity Catalog tables as both Delta and Iceberg.

<Note>
  Integration with the Unity Catalog works for managed and external tables.
  This integration is currently only supported on AWS.
</Note>

<h3 id="configuring-unity-in-databricks">
  Configuring Unity in Databricks
</h3>

To allow ClickHouse to interact with Unity catalog, you need to make sure your Unity Catalog is configured to allow interaction with an external reader. This can be achieved by following the[ "Enable external data access to Unity Catalog"](https://docs.databricks.com/aws/en/external-access/admin) guide.

In addition to enabling external access, ensure the principal configuring the integration has the `EXTERNAL USE SCHEMA` [privilege](https://docs.databricks.com/aws/en/external-access/admin#external-schema) on the schema containing the tables.

Once your catalog is configured, you must generate credentials for ClickHouse. Two different methods can be used, depending on your interaction mode with Unity:

* For Iceberg clients, authenticate with a [service principal](https://docs.databricks.com/aws/en/dev-tools/auth/oauth-m2m).

* For Delta clients, use a Personal Access Token ([PAT](https://docs.databricks.com/aws/en/dev-tools/auth/pat)).

<h3 id="connect-catalog">
  Connect to the catalog
</h3>

With the credentials, you can connect to the relevant endpoint to query the Iceberg or Delta tables.

<Tabs>
  <Tab title="Delta">
    The [Unity catalog](/core/guides/use-cases/data-warehousing/unity-catalog) should be used for accessing data in the Delta format.

    ```sql theme={null}
    SET allow_experimental_database_unity_catalog = 1;

    CREATE DATABASE unity
    ENGINE = DataLakeCatalog('https://<workspace-id>.cloud.databricks.com/api/2.1/unity-catalog')
    SETTINGS warehouse = 'CATALOG_NAME', catalog_credential = '<PAT>', catalog_type = 'unity';
    ```
  </Tab>

  <Tab title="Iceberg">
    ```sql theme={null}
    SET allow_database_iceberg = 1;

    CREATE DATABASE unity
    ENGINE = DataLakeCatalog('https://<workspace-id>.cloud.databricks.com/api/2.1/unity-catalog/iceberg-rest')
    SETTINGS catalog_type = 'rest', catalog_credential = '<client-id>:<client-secret>', warehouse = 'workspace',
    oauth_server_uri = 'https://<workspace-id>.cloud.databricks.com/oidc/v1/token', auth_scope = 'all-apis,sql';
    ```
  </Tab>
</Tabs>

<h3 id="list-tables">
  List tables
</h3>

Once the connection has been established to your catalog, you can list the tables.

```sql theme={null}
SHOW TABLES FROM unity

┌─name───────────────────────────────────────────────┐
│ unity.logs                                         │
│ unity.single_day_log                               │
└────────────────────────────────────────────────────┘

31 rows in set.
```

<h3 id="exploring-table-schemas">
  Exploring table schemas
</h3>

We can use the standard `SHOW CREATE TABLE` command to see how the tables were  created.

<Info>
  **Backticks required**

  Note the need to specify the namespace and the table name, surrounded with backticks - ClickHouse doesn't support more than one namespace.
</Info>

The following assumes querying the REST iceberg catalog:

```sql theme={null}
SHOW CREATE TABLE unity.`icebench.single_day_log`

CREATE TABLE unity.`icebench.single_day_log`
(
    `pull_request_number` Nullable(Int64),
    `commit_sha` Nullable(String),
    `check_start_time` Nullable(DateTime64(6, 'UTC')),
    `check_name` Nullable(String),
    `instance_type` Nullable(String),
    `instance_id` Nullable(String),
    `event_date` Nullable(Date32),
    `event_time` Nullable(DateTime64(6, 'UTC')),
    `event_time_microseconds` Nullable(DateTime64(6, 'UTC')),
    `thread_name` Nullable(String),
    `thread_id` Nullable(Decimal(20, 0)),
    `level` Nullable(String),
    `query_id` Nullable(String),
    `logger_name` Nullable(String),
    `message` Nullable(String),
    `revision` Nullable(Int64),
    `source_file` Nullable(String),
    `source_line` Nullable(Decimal(20, 0)),
    `message_format_string` Nullable(String)
)
ENGINE = Iceberg('s3://...')
```

<h3 id="querying-a-table">
  Querying a table
</h3>

All ClickHouse functions are supported. Again, the namespace and table name should be delimited with backticks.

```sql theme={null}

SELECT count()
FROM unity.`icebench.single_day_log`

┌───count()─┐
│ 282634391 │ -- 282.63 million
└───────────┘

1 row in set. Elapsed: 1.265 sec.
```

For full setup instructions, see the [Unity catalog reference guide](/core/guides/use-cases/data-warehousing/unity-catalog).
