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

> Apache Spark 与 ClickHouse 简介

# 集成 Apache Spark 与 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
        </div>;
};

[Apache Spark](https://spark.apache.org/) 是一个多语言引擎，可在单节点机器或集群上执行数据工程、数据科学和机器学习工作。

连接 Apache Spark 和 ClickHouse 主要有两种方式：

1. [Spark Connector](/zh/integrations/connectors/data-ingestion/apache-spark/spark-native-connector) - Spark Connector 实现了 `DataSourceV2`，并提供自己的 Catalog
   管理功能。目前，这是集成 ClickHouse 与 Spark 的推荐方式。
2. [Spark JDBC](/zh/integrations/connectors/data-ingestion/apache-spark/spark-jdbc) - 使用 [JDBC 数据源](https://spark.apache.org/docs/latest/sql-data-sources-jdbc.html) 来集成 Spark 和 ClickHouse。

<br />

这两种方案都已成功通过测试，并与多种 API 完全兼容，包括 Java、Scala、PySpark 和 Spark SQL。

<div id="spark-runtime-environment">
  ### Spark 运行时环境
</div>

<div id="standard-spark-runtime">
  #### 标准 Spark 运行时环境
</div>

Spark Connector 可在与上游 Apache Spark 运行时高度一致的环境中直接使用，例如 Amazon EMR 或基于 Kubernetes 的 Spark 部署环境。

<div id="managed-spark-platforms">
  #### 托管 Spark 平台
</div>

[AWS Glue](/zh/integrations/connectors/data-ingestion/AWS/glue) 和 [Databricks](/zh/integrations/connectors/data-ingestion/apache-spark/databricks) 等平台会引入额外的抽象层以及特定环境下的行为差异。
虽然核心集成方式不变，但它们可能需要专门的配置和设置步骤。详情请参阅相应的文档页面。
