> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> Introduction to Azure Synapse with ClickHouse

# Integrating Azure Synapse with ClickHouse

export const ClickHouseSupportedBadge = () => {
  return <div className="ClickHouseSupportedBadge">
            <div className="ClickHouseSupportedIcon">
                <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M1.30762 1.39073C1.30762 1.3103 1.37465 1.22986 1.46849 1.22986H2.64824C2.72868 1.22986 2.80912 1.29689 2.80912 1.39073V14.4886C2.80912 14.5691 2.74209 14.6495 2.64824 14.6495H1.46849C1.38805 14.6495 1.30762 14.5825 1.30762 14.4886V1.39073Z" fill="currentColor" />
                    <path d="M4.2832 1.39073C4.2832 1.3103 4.35023 1.22986 4.44408 1.22986H5.62383C5.70427 1.22986 5.7847 1.29689 5.7847 1.39073V14.4886C5.7847 14.5691 5.71767 14.6495 5.62383 14.6495H4.44408C4.36364 14.6495 4.2832 14.5825 4.2832 14.4886V1.39073Z" fill="currentColor" />
                    <path d="M7.25977 1.39073C7.25977 1.3103 7.3268 1.22986 7.42064 1.22986H8.60039C8.68083 1.22986 8.76127 1.29689 8.76127 1.39073V14.4886C8.76127 14.5691 8.69423 14.6495 8.60039 14.6495H7.42064C7.3402 14.6495 7.25977 14.5825 7.25977 14.4886V1.39073Z" fill="currentColor" />
                    <path d="M10.2354 1.39073C10.2354 1.3103 10.3024 1.22986 10.3962 1.22986H11.576C11.6564 1.22986 11.7369 1.29689 11.7369 1.39073V14.4886C11.7369 14.5691 11.6698 14.6495 11.576 14.6495H10.3962C10.3158 14.6495 10.2354 14.5825 10.2354 14.4886V1.39073Z" fill="currentColor" />
                    <path d="M13.2256 6.6057C13.2256 6.52526 13.2926 6.44482 13.3865 6.44482H14.5662C14.6466 6.44482 14.7271 6.51186 14.7271 6.6057V9.27354C14.7271 9.35398 14.6601 9.43442 14.5662 9.43442H13.3865C13.306 9.43442 13.2256 9.36739 13.2256 9.27354V6.6057Z" fill="currentColor" />
                </svg>
            </div>
            ClickHouse Supported
        </div>;
};

export const Image = ({img, alt, size = "lg"}) => {
  const normalizedSize = ["sm", "md", "lg"].includes(size) ? size : "lg";
  return <div className={`ch-image-${normalizedSize}`}>
      <Frame>
        <img src={img} alt={alt} />
      </Frame>
    </div>;
};

<ClickHouseSupportedBadge />

[Azure Synapse](https://azure.microsoft.com/en-us/products/synapse-analytics) is an integrated analytics service that combines big data, data science and warehousing to enable fast, large-scale data analysis.
Within Synapse, Spark pools provide on-demand, scalable [Apache Spark](https://spark.apache.org) clusters that let you run complex data transformations, machine learning, and integrations with external systems.

This article will show you how to integrate the [ClickHouse Spark connector](/docs/integrations/connectors/data-ingestion/apache-spark/spark-native-connector) when working with Apache Spark within Azure Synapse.

<h2 id="add-connector-dependencies">
  Add the connector's dependencies
</h2>

Azure Synapse supports three levels of [packages maintenance](https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-azure-portal-add-libraries):

1. Default packages
2. Spark pool level
3. Session level

<br />

Follow the [Manage libraries for Apache Spark pools guide](https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-manage-pool-packages) and add the following required dependencies to your Spark application

* `clickhouse-spark-runtime-{spark_version}_{scala_version}-{connector_version}.jar` - [official maven](https://mvnrepository.com/artifact/com.clickhouse.spark)
* `clickhouse-jdbc-{java_client_version}-all.jar` - [official maven](https://mvnrepository.com/artifact/com.clickhouse/clickhouse-jdbc)

Please visit our [Spark Connector Compatibility Matrix](/docs/integrations/connectors/data-ingestion/apache-spark/spark-native-connector#compatibility-matrix) docs to understand which versions suit your needs.

<h2 id="add-clickhouse-as-catalog">
  Add ClickHouse as a catalog
</h2>

There are a variety of ways to add Spark configs to your session:

* Custom configuration file to load with your session
* Add configurations via Azure Synapse UI
* Add configurations in your Synapse notebook

Follow this [Manage Apache Spark configuration](https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-azure-create-spark-configuration)
and add the [connector required Spark configurations](/docs/integrations/connectors/data-ingestion/apache-spark/spark-native-connector#register-the-catalog-required).

For instance, you can configure your Spark session in your notebook with these settings:

```python theme={null}
%%configure -f
{
    "conf": {
        "spark.sql.catalog.clickhouse": "com.clickhouse.spark.ClickHouseCatalog",
        "spark.sql.catalog.clickhouse.host": "<clickhouse host>",
        "spark.sql.catalog.clickhouse.protocol": "https",
        "spark.sql.catalog.clickhouse.http_port": "<port>",
        "spark.sql.catalog.clickhouse.user": "<username>",
        "spark.sql.catalog.clickhouse.password": "password",
        "spark.sql.catalog.clickhouse.database": "default"
    }
}
```

Make sure it will be in the first cell as follows:

<Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/azure-synapse/spark_notebook_conf.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=f45f76cb318c0c65a1ecae90edd158e8" size="xl" alt="Setting Spark configurations via notebook" border width="1255" height="407" data-path="images/integrations/data-ingestion/azure-synapse/spark_notebook_conf.webp" />

Please visit the [ClickHouse Spark configurations page](/docs/integrations/connectors/data-ingestion/apache-spark/spark-native-connector#configurations) for additional settings.

<Info>
  When working with ClickHouse Cloud Please make sure to set the [required Spark settings](/docs/integrations/connectors/data-ingestion/apache-spark/spark-native-connector#clickhouse-cloud-settings).
</Info>

<h2 id="setup-verification">
  Setup verification
</h2>

To verify that the dependencies and configurations were set successfully, please visit your session's Spark UI, and go to your `Environment` tab.
There, look for your ClickHouse related settings:

<Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/azure-synapse/spark_ui_ch_settings.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=954767d8d40dedc2823122451bba4ddd" size="xl" alt="Verifying ClickHouse settings using Spark UI" border width="1499" height="280" data-path="images/integrations/data-ingestion/azure-synapse/spark_ui_ch_settings.webp" />

<h2 id="additional-resources">
  Additional resources
</h2>

* [ClickHouse Spark Connector Docs](/docs/integrations/connectors/data-ingestion/apache-spark/index)
* [Azure Synapse Spark Pools Overview](https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-overview)
* [Optimize performance for Apache Spark workloads](https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-performance)
* [Manage libraries for Apache Spark pools in Synapse](https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-manage-pool-packages)
* [Manage Apache Spark configuration in Synapse](https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-azure-create-spark-configuration)
