# BigQuery

<figure><img src="/files/A7HPMGHvlW4yiBb1s7zJ" alt=""><figcaption></figcaption></figure>

Codatumを使用してBigQueryに接続し、クエリの実行やデータの管理ができます。

## 設定方法

#### BigQuery側の作業

まず、BigQueryコンソールで以下の操作を行います:

* サービスアカウントとサービスアカウントキーを生成する
* 対象のプロジェクトに以下の役割または権限を付与する:
  * `BigQuery Job User（BigQuery ジョブユーザー）` ロールまたは以下の権限:
    * `bigquery.jobs.create`
  * `BigQuery Read Session User（BigQuery 読み取りセッション ユーザー）` ロールまたは以下の権限:
    * `bigquery.readsessions.create`
    * `bigquery.readsessions.getData`
    * `bigquery.readsessions.update`
  * あとで必要となるため、対象の `プロジェクトID` をメモしておいてください
* 対象のデータセットに以下の役割または権限を付与する:
  * `BigQuery Data Viewer（BigQuery データ閲覧者）` ロールまたは以下の権限:
    * `bigquery.tables.getData`
    * `bigquery.datasets.get`
    * `bigquery.tables.get`
    * `bigquery.tables.list`
* (オプション) プロジェクトIDの入力を省略してデータセットテーブル情報を同期したい場合は、対象のプロジェクトに以下の権限を付与してください：
  * `resourcemanager.projects.get`

#### Codatum側の作業

最後に、Codatumで新しいコネクションを作成します。

1. `ワークスペース設定`の`コネクション`から`コネクションを追加`を選択
2. `コネクション名`を入力
3. `アクセスレベル`を選択
4. `ファイルアップロード`を使ってサービスアカウントキーをアップロード
5. `プロジェクトID`を入力
   * 上記BigQuery側の作業でメモしておいた `プロジェクトID` を使用
6. `同期対象`にデータセットを追加

## INFORMATION\_SCHEMAを使用して検索する

対象のプロジェクトに`bigquery.admin`権限を付与すると、同期していないデータセットのテーブルもINFORMATION\_SCHEMAテーブルを使って検索できます。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.codatum.jp/connect-and-manage-data/supported-warehouses/bigquery.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
