2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

DataZone に Redshift のテーブルを連携してみた

2
Last updated at Posted at 2023-07-09

はじめに

前回の記事で、DataZone の QuickStart を実行しました。前回は S3 にデータを格納して、Athena 経由でクエリーを行う内容を確認しました。DataZone は、Redshift とも連携機能があるので、この記事で Redshift との連携を確認してみます。

Redshift Provisioned を用意

Redshift の Provisioned cluster を用意します。

image-20230703000202027.png

Redshift に接続します。

psql \
-h redshift-cluster-1.chigetqqkdgx.us-east-1.redshift.amazonaws.com \
-p 5439 \
-U awsuser \
-d tpch_3tb

次のように、 TPC-H の 8テーブルを準備しました。

  • tpch_3tb データベース
  • public スキーマ
tpch_3tb=# \dt
          List of relations
 schema |   name   | type  |  owner
--------+----------+-------+---------
 public | customer | table | awsuser
 public | lineitem | table | awsuser
 public | nation   | table | awsuser
 public | orders   | table | awsuser
 public | part     | table | awsuser
 public | partsupp | table | awsuser
 public | region   | table | awsuser
 public | supplier | table | awsuser
(8 rows)

DataZone のデータソースに Redshift を追加

DataZone に Redshift を連携させます。

image-20230703011959759.png

Data source のタブで Create data source を選択します。

image-20230703012023371.png

適当に名前を指定して、連携したい DataZone 上の Domain を指定します。

image-20230703012427442.png

Redshift 上の Database tpch_3tb を指定します。

image-20230703012622648.png

このあたりの IAM Role はよくわからないので、自動生成に任せます。

image-20230703013051769.png

対象の Project を指定して、Create を押します。

image-20230703013339914.png

一見、Data source には何も追加されていないように見えますが、Filter domain を選択します。

image-20230703013831391.png

IT ドメインを指定します。

image-20230703014041029.png

Redshift Cluster が登録されていることを確認しました。

image-20230703014104488.png

IT Project 上で Redshift のデータを Publish

DataZone の IT Project 上で Publish Data を押して、Redshift のデータをデータカタログに公開します。

image-20230703014507821.png

適当に Job の名前を入れます。

image-20230703014609351.png

Data Source で Redshift が選択できるようになっています。redshift-cluster を選択します。

image-20230703014648643.png

Redshift 上のスキーマを指定します。public スキーマを指定します。

image-20230703015713480.png

Run once を選択して、Create を押します。

image-20230703014752560.png

REQUESTED になりました。

image-20230703014806057.png

一定時間後、SUCCESS に変わり、Redshift 上の 8 テーブルが追加されました。 

image-20230703021357744.png

Glue DataCatalog 上にも自動的に Database が作成され、Table が追加されています

image-20230703021536974.png

Draft として 8 テーブルが認識されています。

image-20230703022129789.png

日本語のメタデータを入力するため、適当にテーブルを選択します。

image-20230703022413875.png

Edit を押します。

image-20230703022444466.png

テーブル名のわかりやすい名前をいれます。

image-20230703022514010.png

スキーマ情報も自動認識されています。

image-20230703022622364.png

日本語の説明を入れて、Active に変更します。

image-20230703022944850.png

データカタログで検索

DataZone の検索ボックスで、「顧客」を検索します。

image-20230703023130469.png

このカタログ上では、Redshift Cluster の名前や、テーブル名がわかります。

image-20230703023248893.png

スキーマ情報もわかります。

image-20230703024149956.png

(動作しなかった)サブスクライブ

この Redshift のデータをサブスクライブができます。

image-20230703024227880.png

サブスクライブします。

image-20230703024258329.png

管理者アカウントに申請がきています。

image-20230703024512645.png

承認します。

image-20230703024550913.png

Not granted となっていました。

image-20230703024735099.png

Athena 上でも出てこない。

image-20230703024906804.png

ちなみに、AWS Document 上では、Redshift でもクエリーができるようでした。この辺りは今後確認します。

2
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?