> ## 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.

> 初めての BigQuery ClickPipe を作成するためのステップごとのガイド。

# 初めての BigQuery ClickPipe の作成

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>;
};

export const PrivatePreviewBadge = () => {
  return <div className="privatePreviewBadge">
            <div className="privatePreviewIcon">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M5.33301 6.66667V4.66667V4.66667C5.33301 3.194 6.52701 2 7.99967 2V2C9.47234 2 10.6663 3.194 10.6663 4.66667V4.66667V6.66667" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path d="M8.00033 9.33337V11.3334" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path fillRule="evenodd" clipRule="evenodd" d="M11.333 14H4.66634C3.92967 14 3.33301 13.4033 3.33301 12.6666V7.99996C3.33301 7.26329 3.92967 6.66663 4.66634 6.66663H11.333C12.0697 6.66663 12.6663 7.26329 12.6663 7.99996V12.6666C12.6663 13.4033 12.0697 14 11.333 14Z" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
        </div>
            {'ClickHouse Cloud でのプライベートプレビュー'}
        </div>;
};

<PrivatePreviewBadge />

<Note>
  [こちら](https://clickhouse.com/cloud/clickpipes/bigquery-connector)からプライベートプレビューのウェイトリストに登録できます。
</Note>

BigQuery ClickPipe は、BigQuery から ClickHouse Cloud へデータを取り込むための、フルマネージドで耐障害性に優れた仕組みです。プライベートプレビューでは、BigQuery のデータセットを探索やプロトタイピング向けに一括で読み込めるよう、**初期ロード** レプリケーション方式をサポートしています。将来的には **CDC** もサポートされる予定です。それまでは、初期ロード完了後に BigQuery のエクスポートデータを ClickHouse Cloud に継続的に同期する方法として、[Google Cloud Storage ClickPipe](/docs/ja/integrations/clickpipes/object-storage/google-cloud-storage/overview) の利用を推奨します。

BigQuery ClickPipes は、ClickPipes UI を使用して手動でデプロイおよび管理できるほか、[OpenAPI](/docs/ja/integrations/clickpipes/programmatic-access/openapi) や [Terraform](/docs/ja/integrations/clickpipes/programmatic-access/terraform) を使用してプログラムからデプロイおよび管理することもできます。

<div id="pre-requisites">
  ## 前提条件
</div>

* GCP プロジェクトで [サービス アカウント](https://docs.cloud.google.com/iam/docs/service-account-overview) と [IAM ロール](https://docs.cloud.google.com/iam/docs/roles-overview) を管理する権限が必要です。権限がない場合は、管理者に支援を依頼してください。[公式ドキュメント](https://docs.cloud.google.com/iam/docs/service-accounts-create)に従って、必要最小限の[権限](/docs/ja/integrations/clickpipes/bigquery/overview#permissions)を付与した専用のサービス アカウントを作成することを推奨します。

* 初期ロードでは、ステージング用にユーザーが用意した Google Cloud Storage (GCS) バケットが必要です。[公式ドキュメント](https://docs.cloud.google.com/storage/docs/creating-buckets)に従って、ClickPipe 専用のバケットを作成することを推奨します。将来的には、この中間バケットは ClickPipes が提供および管理する予定です。

<Steps>
  <Step title="データソースを選択する" id="1-select-the-data-source">
    **1.** ClickHouse Cloud で、メインナビゲーションメニューから **Data sources** を選択し、**Create ClickPipe** をクリックします。

    <Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/cp_step0.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=fb04bb07245be43cb784fa68cee62287" alt="インポートを選択" size="lg" border width="2606" height="790" data-path="images/integrations/data-ingestion/clickpipes/cp_step0.webp" />

    **2.** **BigQuery** タイルをクリックします。

    <Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/bigquery/cp_step1.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=a6e6b584cec7de0aa47fb4fe081455c1" alt="BigQuery タイルを選択" size="lg" border width="2680" height="1070" data-path="images/integrations/data-ingestion/clickpipes/bigquery/cp_step1.webp" />
  </Step>

  <Step title="ClickPipe 接続を設定する" id="2-setup-your-clickpipe-connection">
    新しい ClickPipe を設定するには、BigQuery データウェアハウスへの接続方法と認証情報に加え、ステージング用の GCS バケットを指定する必要があります。

    **1.** ClickPipes 用に作成したサービス アカウントの `.json` 秘密鍵をアップロードします。サービス アカウントに、必要最小限の [permissions](/docs/ja/integrations/clickpipes/bigquery/overview#permissions) が付与されていることを確認してください。

    <Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/bigquery/cp_step2.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=38f3a1c3d43a4f990720989ef77ffab8" alt="サービスアカウントの秘密鍵をアップロード" size="lg" border width="2684" height="926" data-path="images/integrations/data-ingestion/clickpipes/bigquery/cp_step2.webp" />

    **2.** **Replication method** を選択します。プライベートプレビューでは、サポートされているオプションは [**Initial load only**](/docs/ja/integrations/clickpipes/bigquery/overview#initial-load) のみです。

    **3.** 初期ロード中のデータをステージングするための GCS バケットのパスを指定します。

    **4.** **Next** をクリックして検証します。
  </Step>

  <Step title="ClickPipe を設定する" id="3-configure-your-clickpipe">
    BigQuery データセットのサイズや、同期するテーブルの合計サイズによっては、ClickPipe のデフォルトのインジェスト設定を調整する必要がある場合があります。
  </Step>

  <Step title="テーブルを設定する" id="4-configure-tables">
    **1.** BigQuery テーブルのレプリケーション先となる ClickHouse データベースを選択します。既存のデータベースを選択することも、新しく作成することもできます。

    **2.** レプリケートするテーブルと、必要に応じてカラムを選択します。一覧には、指定したサービス アカウントがアクセスできるデータセットのみが表示されます。

    <Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/bigquery/cp_step3.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=47b2da2a8c72f83db98ad1e0dba001fd" alt="権限" size="lg" border width="2682" height="1430" data-path="images/integrations/data-ingestion/clickpipes/bigquery/cp_step3.webp" />

    **3.** 選択した各テーブルについて、**Advanced settings** > **Use a custom sorting key** で必ずカスタムソートキーを定義してください。将来的には、ソートキーはアップストリームのデータベースにある既存のクラスタリングキーまたはパーティション化キーに基づいて自動的に推定されるようになります。

    <Warning>
      ClickHouse でクエリ性能を最適化するには、レプリケートテーブルに [ソートキー](/docs/ja/concepts/best-practices/choosing-a-primary-key) を必ず定義する必要があります。そうしない場合、ソートキー は `tuple()` に設定されます。これはプライマリインデックスが作成されないことを意味し、ClickHouse はそのテーブルに対するすべてのクエリでフルテーブルスキャンを実行します。
    </Warning>

    <Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/bigquery/cp_step4.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=453669eac94ab18196d9fb5dca67cba0" alt="権限" size="lg" border width="2676" height="854" data-path="images/integrations/data-ingestion/clickpipes/bigquery/cp_step4.webp" />
  </Step>

  <Step title="権限を設定する" id="6-configure-permissions">
    最後に、ClickPipes の内部ユーザーに対する権限を設定できます。

    **Permissions:** ClickPipes は、宛先テーブルにデータを書き込むための専用ユーザーを作成します。この内部ユーザーには、カスタムロールまたは事前定義されたロールのいずれかを割り当てられます。

    * `Full access`: クラスターへのフルアクセス。宛先テーブルで materialized view または Dictionary を使用する場合に必要です。
    * `Only destination`: 宛先テーブルへの INSERT 権限のみ。
  </Step>

  <Step title="設定を完了する" id="7-complete-setup">
    **Create ClickPipe** をクリックして設定を完了します。概要ページにリダイレクトされ、そこで初期ロードの進行状況を確認したり、BigQuery ClickPipes の詳細をクリックして表示したりできます。

    <Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/bigquery/cp_step5.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=f8eee834cd7e1aaa8531f1536fada68c" alt="権限" size="lg" border width="2682" height="918" data-path="images/integrations/data-ingestion/clickpipes/bigquery/cp_step5.webp" />
  </Step>
</Steps>
