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

> Amazon QuickSight は、統合型のビジネスインテリジェンス（BI）により、データドリブンな組織を支援します。

# QuickSight

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

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

QuickSight は、公式の MySQL データソースと Direct Query モードを使用して、MySQL インターフェイス経由でオンプレミスの ClickHouse 環境 (23.11+) に接続できます。

<div id="on-premise-clickhouse-server-setup">
  ## オンプレミスでの ClickHouse サーバー のセットアップ
</div>

MySQL インターフェイスを有効にした ClickHouse サーバー の設定方法については、[公式ドキュメント](/ja/concepts/features/interfaces/mysql)を参照してください。

ClickHouse サーバー の `config.xml` にエントリを追加するだけでなく

```xml theme={null}
<clickhouse>
    <mysql_port>9004</mysql_port>
</clickhouse>
```

また、MySQL インターフェイスを使用するユーザーでは、[ダブル SHA1 によるパスワード暗号化](/ja/concepts/features/configuration/settings/settings-users#user-namepassword)の使用が*必須*です。

シェルからダブル SHA1 で暗号化したランダムなパスワードを生成するには、次のようにします。

```shell theme={null}
PASSWORD=$(base64 < /dev/urandom | head -c16); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-'
```

出力は以下のようになります。

```text theme={null}
LZOQYnqQN4L/T6L0
fbc958cc745a82188a51f30de69eebfc67c40ee4
```

1行目は生成されたパスワードで、2行目はClickHouseの設定に使用するハッシュです。

以下は、生成されたハッシュを使う `mysql_user` の設定例です。

`/etc/clickhouse-server/users.d/mysql_user.xml`

```xml theme={null}
<users>
    <mysql_user>
        <password_double_sha1_hex>fbc958cc745a82188a51f30de69eebfc67c40ee4</password_double_sha1_hex>
        <networks>
            <ip>::/0</ip>
        </networks>
        <profile>default</profile>
        <quota>default</quota>
    </mysql_user>
</users>
```

`password_double_sha1_hex` エントリを、ご自身で生成したダブル SHA1 ハッシュに置き換えてください。

QuickSight では、MySQL ユーザーのプロファイルにいくつか追加の設定が必要です。

`/etc/clickhouse-server/users.d/mysql_user.xml`

```xml theme={null}
<profiles>
    <default>
        <prefer_column_name_to_alias>1</prefer_column_name_to_alias>
        <mysql_map_string_to_text_in_show_columns>1</mysql_map_string_to_text_in_show_columns>
        <mysql_map_fixed_string_to_text_in_show_columns>1</mysql_map_fixed_string_to_text_in_show_columns>
    </default>
</profiles>
```

ただし、デフォルトのプロファイルではなく、MySQLユーザーが使用する別のプロファイルに割り当てることを推奨します。

最後に、ClickHouseサーバーが必要なIPアドレスで待ち受けるように設定します。
`config.xml` で、すべてのアドレスで待ち受けるには、以下のコメントアウトを外します。

```bash theme={null}
<listen_host>::</listen_host>
```

`mysql` バイナリが利用できる場合は、コマンドラインから接続をテストできます。
上記のサンプルのユーザー名 (`mysql_user`) とパスワード (`LZOQYnqQN4L/T6L0`) を使用すると、コマンドラインは次のようになります。

```bash theme={null}
mysql --protocol tcp -h localhost -u mysql_user -P 9004 --password=LZOQYnqQN4L/T6L0
```

```response theme={null}
mysql> show databases;
+--------------------+
| name               |
+--------------------+
| INFORMATION_SCHEMA |
| default            |
| information_schema |
| system             |
+--------------------+
4 rows in set (0.00 sec)
Read 4 rows, 603.00 B in 0.00156 sec., 2564 rows/sec., 377.48 KiB/sec.
```

<div id="connecting-quicksight-to-clickhouse">
  ## QuickSight を ClickHouse に接続する
</div>

まず、[https://quicksight.aws.amazon.com](https://quicksight.aws.amazon.com) にアクセスし、Datasets に移動して「New dataset」をクリックします。

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_01.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=49b1475d7a434f610ae6cf35c3f40e42" alt="Datasets セクションで New dataset ボタンが表示されている Amazon QuickSight ダッシュボード" border width="1555" height="1038" data-path="images/integrations/data-visualization/quicksight_01.webp" />

<br />

QuickSight に付属する公式の MySQL コネクタ (名前は **MySQL**) を検索します。

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_02.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=cc25cccdea446662d9957a7433f0281f" alt="検索結果で MySQL がハイライト表示されている QuickSight のデータソース選択画面" border width="2006" height="1040" data-path="images/integrations/data-visualization/quicksight_02.webp" />

<br />

接続情報を指定します。MySQL インターフェイスのポートはデフォルトでは 9004 ですが、
サーバー設定によって異なる場合がある点に注意してください。

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_03.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=8d12ce47aad260d73c210d436d39653c" alt="hostname、ポート、データベース、認証情報のフィールドを含む QuickSight の MySQL 接続設定フォーム" border width="1059" height="1143" data-path="images/integrations/data-visualization/quicksight_03.webp" />

<br />

次に、ClickHouse からデータを取得する方法は 2 つあります。1 つ目は、一覧からテーブルを選択する方法です。

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_04.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=c906b615fff9e0b735fc0df219a06b35" alt="ClickHouse で利用可能なデータベーステーブルが表示されている QuickSight のテーブル選択インターフェイス" border width="1061" height="845" data-path="images/integrations/data-visualization/quicksight_04.webp" />

<br />

また、データを取得するためのカスタム SQL を指定することもできます。

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_05.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=8d200a00f885e178c7279ca430ec0aa8" alt="ClickHouse からデータを取得するための QuickSight のカスタム SQL クエリエディター" border width="1061" height="845" data-path="images/integrations/data-visualization/quicksight_05.webp" />

<br />

「Edit/Preview data」をクリックすると、解析されたテーブル構造を確認したり、必要に応じてカスタム SQL を調整したりできます。

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_06.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=29b929b76b27810accdf9c118a0ddc6e" alt="カラムとサンプルデータを含むテーブル構造が表示されている QuickSight のデータプレビュー" border width="1743" height="1277" data-path="images/integrations/data-visualization/quicksight_06.webp" />

<br />

UI の左下隅で「Direct Query」モードが選択されていることを確認してください。

<Image size="md" img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/svLCKm9RWi4jibqG/images/integrations/data-visualization/quicksight_07.webp?fit=max&auto=format&n=svLCKm9RWi4jibqG&q=85&s=e17b486cb3b7a2a0109569697b38dbe8" alt="左下隅で Direct Query モードのオプションがハイライト表示されている QuickSight インターフェイス" border width="677" height="341" data-path="images/integrations/data-visualization/quicksight_07.webp" />

<br />

これで、データセットを公開し、新しい可視化を作成できます。

<div id="known-limitations">
  ## 既知の制限
</div>

* SPICE インポートは想定どおりに動作しないため、代わりに Direct Query モードを使用してください。詳細は [#58553](https://github.com/ClickHouse/ClickHouse/issues/58553) を参照してください。
